[英]Symfony2 service not registering
When I do php app/console service:debug
my service is listed as expected, but when I access my bundle from web, or by functional tests - I get: 当我执行php app/console service:debug
我的服务已按预期列出,但是当我从Web或通过功能测试访问我的捆绑软件时-我得到:
Uncaught PHP Exception Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: "You have requested a non-existent service "xx.handler"." “未捕获的PHP异常Symfony \\ Component \\ DependencyInjection \\ Exception \\ ServiceNotFoundException:”您已请求不存在的服务“ xx.handler”。 at xx/app/bootstrap.php.cache line 2031 {"exception":"[object] (Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: You have requested a non-existent service \\"xx.handler\\". at xx/app/bootstrap.php.cache:2031)"} [] 在xx / app / bootstrap.php.cache中,第2031行{“ exception”:“ [object](Symfony \\ Component \\ DependencyInjection \\ Exception \\ ServiceNotFoundException:您已请求不存在的服务\\” xx.handler \\“。) /app/bootstrap.php.cache:2031)“} []
I also attempted to type die('di');
我也尝试键入die('di');
in the DependecyInjection Extension, which is never triggered when using the browser to access the controller, but it fires with php app/console service:debug
在DependecyInjection扩展中,使用浏览器访问控制器时不会触发,但会在php app/console service:debug
触发php app/console service:debug
How to resolve the above error, such that accessing my controller will register my service? 如何解决以上错误,以便访问我的控制器将注册我的服务?
Try: 尝试:
app/console cache:clear
Also - It's better to debug your code on dev mod via app_dev.php 另外-最好通过app_dev.php在dev mod上调试代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.