我对 Symfony 很陌生,我正在尝试使用数据库中的用户创建一个登录表单。
到目前为止,我知道我必须将 login_check 放在防火墙后面,而不是为其创建控制器,但我仍然收到此错误:
An exception has been thrown during the rendering of a template ("Route "login_check" does not exist.") in EventBundle:Security:login.html.twig at line 11.
我的security.yml:
jms_security_extra:
secure_all_services: false
expressions: true
security:
encoders:
SocialGeo\EventBundle\Entity\User:
algorithm: sha512
encode-as-base64: true
iterations: 10
role_hierarchy:
ROLE_USER: ROLE_USER
ROLE_DISTRICTWORKER: ROLE_USER
ROLE_CITYWORKER: ROLE_DISTRICTWORKER
ROLE_ADMIN: ROLE_CITYWORKER
ROLE_SUPERADMIN: ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH
providers:
administrators:
entity: { class: SocialGeo\EventBundle\Entity\User, property: username }
firewalls:
main:
pattern: /.*
form_login:
login_path: /login
check_path: /login_check
remember_me: true
logout:
path: /logout
target: /
security: true
anonymous: true
路由.yml:
EventBundle_login:
pattern: /login
defaults: { _controller: EventBundle:Security:login }
requirements:
_method: GET|POST
EventBundle_login_check:
pattern: /login_check
EventBundle_logout:
pattern: /logout
我的树枝模板:
{% extends 'EventBundle::layout.html.twig' %}
{% block title %}Login{% endblock %}
{% block body %}
{% if error %}
<div>{{ error.message }}</div>
{% endif %}
<form action="{{ path('login_check') }}" method="post">
<label for="username">Username</label>
<input id="username" type="text" name="_username" value="{{ last_username }}" />
<label for="password">Password</label>
<input id="password" type="password" name="_password" />
<input type="submit" name="login" />
</form>
{% endblock %}
有谁知道我为什么会收到这个错误?