我正在尝试在我的项目中构建登录和注册表单和进程,但由于某种原因我得到循环引用错误。注册工作正常。问题是我在构建登录表单时。我正在使用这里的教程:
http://symfony.com/doc/current/cookbook/security/form_login_setup.html
当我添加它时,项目仍然有效:
firewalls:
default:
anonymous: ~
http_basic: ~
form_login:
login_path: /login_user
check_path: /login_check
但是当我在控制器中制作路线时,我得到错误:
<?php
// src/AppBundle/Controller/SecurityController.php
// ...
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class SecurityController extends Controller
{
/**
* @Route("/login_user", name="login_route")
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render(
'Frontend/navbar.html.twig',
array(
// last username entered by the user
'last_username' => $lastUsername,
'error' => $error,
)
);
}
/**
* @Route("/login_check", name="login_check")
*/
public function loginCheckAction()
{
// this controller will not be executed,
// as the route is handled by the Security system
}
}
这是我的routing.dev.yml:
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
_main:
resource: routing.yml
这里有什么问题?