我正在生产服务器中部署基于Symfony2的应用程序,但我无法登录。 我收到一条错误消息,指出缺少路由/ login_check的控制器参数。 这应该由防火墙配置处理,该配置包含在security.yml文件中,security.yml文件包含在app / config / config.yml文件中。 应用程序在我的开发机器中部署得很好,我可以登录(使用prod配置)但是当我尝试访问/ login_check路由时,我在服务器中得到500错误。 任何提示都将非常有用并且受到欢迎。 提前谢谢。
我的prod.log中出现以下错误:
[2014-06-26 00:52:56] security.DEBUG: Write SecurityContext in the session [] []
[2014-06-26 00:53:12] request.INFO: Matched route "login_check" (parameters: "_route": "login_check") [] []
[2014-06-26 00:53:12] security.INFO: Populated SecurityContext with an anonymous Token [] []
[2014-06-26 00:53:12] security.INFO: No expression found; abstaining from voting. [] []
[2014-06-26 00:53:12] request.WARNING: Unable to look for the controller as the "_controller" parameter is missing [] []
[2014-06-26 00:53:12] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Unable to find the controller for path "/login_check". Maybe you forgot to add the matching route in your routing configuration?" at /homepages/36/d516172930/htdocs/covivedev/app/bootstrap.php.cache line 995 [] []
[2014-06-26 00:53:12] security.DEBUG: Write SecurityContext in the session [] []
这是我的app / config / config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
framework:
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: %kernel.debug%
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_proxies: ~
session: ~
fragments: ~
# Twig Configuration
twig:
debug: %kernel.debug%
strict_variables: %kernel.debug%
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
filters:
cssrewrite: ~
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: smtp
host: ssl://smtp.gmail.com
username: max21campos@gmail.com
password: xxxxx
spool: { type: memory }
我的app / config / security.yml如下所示:
jms_security_extra:
secure_all_services: false
expressions: true
security:
encoders:
PromoMails\CoviveBundle\Entity\Usuario:
algorithm: sha1
encode_as_base64: false
iterations: 1
providers:
covive_provider:
entity:
class: PromoMailsCoviveBundle:Usuario
property: username
firewalls:
covive:
pattern: /
anonymous: ~
provider: covive_provider
security: true
form_login:
login_path: /
check_path: /login_check
always_use_default_target_path: true
default_target_path: /home
use_referer: true
logout:
path: /logout
target: /
remember_me:
key: SaveUser
lifetime: 0
path: /.*
domain: ~
access_control:
- { path: ^/login_check, roles: IS_AUTHENTICATED_ANONYMOUSLY}
- { path: ^/vendedor, roles: ROLE_VENDEDOR }
我的app / config / routing.yml只包含BundleRouting:
promo_mails_covive:
resource: "@PromoMailsCoviveBundle/Resources/config/routing.yml"
prefix: /
我的捆绑路由具有以下内容:
promo_mails_covive_homepage:
pattern: /
defaults:
_controller: PromoMailsCoviveBundle:Default:index
home:
pattern: /home
defaults:
_controller: PromoMailsCoviveBundle:Default:home
login_check:
pattern: /login_check
logout:
pattern: /logout
答案 0 :(得分:0)
发生错误:
[2014-06-26 00:53:12] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Unable to find the controller for path "/login_check". Maybe you forgot to add the matching route in your routing configuration?"[...]
在 routing.yml 中,您可能必须添加_controller:
login_check:
pattern: /login_check
defaults: { _controller: YourBundle:ControllerName:login_check }
此外,您可以在这里找到有关routing的Symfony 2文档。
答案 1 :(得分:0)
您可以检查的是修改security.yml
中防火墙语句的顺序如果读者可以确认,那就太棒了。 错误消息说添加_controller行,但这不是真正的问题;它只是一个建议,login_check URL不需要_controller语句;