簡體   English   中英

樹枝找不到Symfony3服務

[英]Symfony3 service not found by twig

我有以下問題。 我有服務。 我想在每個TWIG模板中使用該服務。 但是找不到我的服務。

我收到以下錯誤:

ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "twig" has a dependency on a non-existent service "appbundle\service\categoryhandler".

請注意,該服務沒有被駝峰包裝,而在我的config.yml中卻被駝峰包裝。

這是我的config.yml部分

# Twig Configuration
twig:
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'
    globals:
        categories: '@AppBundle\Service\CategoryHandler'

我已經添加了PHP模板引擎( 在搜索我的問題時發現了這個“解決方案” )。

templating:
        engines: ['twig', 'php']

我遵循了Symfony的這份文檔

看起來找不到您的CategoryHandler服務。

已經注冊了嗎? 或者,是否啟用了自動加載? http://symfony.com/doc/current/service_container.html#creating-configuring-services-in-the-container

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM