我在symfony2中有一个程序,我有一个带Cpanel的apache服务器
该项目在本地工作正常,但当我在服务器上传它时,它给了我这个错误:
Whoops, looks like something went wrong.
1/1 ServiceNotFoundException: The service "security.firewall.map.context.secured_area" has a dependency on a non-existent service "authentication_handler".
in /home/doobin/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php line 59
at CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(array(object(Reference), object(Reference), object(Definition), object(Definition), 'secured_area', object(Reference), object(Definition), array('check_path' => '/user/login_check', 'use_forward' => false, 'username_parameter' => '_username', 'password_parameter' => '_password', 'csrf_parameter' => '_csrf_token', 'intention' => 'authenticate', 'post_only' => true), object(Reference), object(Reference))) in /home/doobin/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php line 43
at CheckExceptionOnInvalidReferenceBehaviorPass->processDefinition(object(Definition)) in /home/doobin/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php line 54
at CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(array(object(Definition), object(Definition), object(Definition), object(Definition), object(Definition), object(Definition), object(Definition))) in /home/doobin/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php line 52
at CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(array(array(object(Definition), object(Definition), object(Definition), object(Definition), object(Definition), object(Definition), object(Definition)), object(Definition))) in /home/doobin/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php line 43
at CheckExceptionOnInvalidReferenceBehaviorPass->processDefinition(object(Definition)) in /home/doobin/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php line 37
at CheckExceptionOnInvalidReferenceBehaviorPass->process(object(ContainerBuilder)) in /home/doobin/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php line 119
at Compiler->compile(object(ContainerBuilder)) in /home/doobin/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 453
at ContainerBuilder->compile() in /home/doobin/app/bootstrap.php.cache line 950
at Kernel->buildContainer() in /home/doobin/app/bootstrap.php.cache line 859
at Kernel->initializeContainer() in /home/doobin/app/bootstrap.php.cache line 571
at Kernel->boot() in /home/doobin/app/bootstrap.php.cache line 614
at Kernel->handle(object(Request)) in /home/doobin/public_html/app_dev.php line 28
我不知道该怎么办? 我已经给予了正确的权限来缓存和记录目录,并编辑了本地IP的配置,但没有更改错误!
任何帮助都是适当的
答案 0 :(得分:1)
$ app/console container:debug | grep authentication_handler
如果结果为空,则表示您尚未配置服务
答案 1 :(得分:1)
这意味着它无法找到您的身份验证服务。
阅读本文,这可能有助于您清理security.yml
就像你提到的那样;
您需要这样的身份验证处理程序services.yml。
services:
authentication_handler:
class: Acme\TestBundle\Handler\AuthenticationHandler
calls:
- [ setContainer, [ @service_container ] ]
编写security.yml的正确方法是;
security:
firewalls:
admin_area:
form_login:
success_handler: authentication_handler
在将项目上传到服务器之前,请清除您的开发缓存并测试您的开发(web / app_dev.php)。
然后转到生产并清除其prod-cache并进行测试。如果您在本地进行了正确的测试(web / app.php),您将不会在服务器中遇到这些错误。
希望这会有所帮助。干杯!