我在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的配置,但没有错误的更改!
任何帮助都会通知
这意味着它找不到您的身份验证服务。
阅读这篇文章,这可能会帮助你清理你的安全。yml
Symfony2登录和安全
就像你提到的;
您需要一个像这样的身份验证处理程序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)
然后转移到生产并清除其生产缓存和测试。如果你在本地正确地测试服务器(web/app.php),你就不会在服务器中遇到这些错误
希望这能有所帮助。干杯
$ app/console container:debug | grep authentication_handler
如果结果为空,则表示您尚未配置服务