我在項目symfony2.3
版本開發的一個做模板壓倒一切的FosUserBundle
。 請嘗試以下代碼,可以幫助你
config.yml
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
FrontBundle /控制器/ LoginController.php
<?php
namespace Dhi\UserBundle\Controller;
use FOS\UserBundle\Controller\SecurityController as Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\RedirectResponse;
class LoginController extends Controller
{
protected function loginController(array $data)
{
$request = $this->get('request');
return $this->render('FrontBundle:login:login.html.twig');
}
}
FrontBundle /資源/視圖/登錄/ login.html.twig
{% extends "DhiUserBundle::layout.html.twig" %}
{% trans_default_domain 'FOSUserBundle' %}
{% block body %}
{% block fos_user_content %}
{% trans_default_domain 'FOSUserBundle' %}
// Your login form code here
{% endblock fos_user_content %}
{% endblock body %}
在答案中包含更多詳細信息,並避免僅提供一些外部鏈接。 – Masoud
我做到了,它更好嗎? – NoTra
您對字符數沒有任何限制。爲什麼不復制和粘貼(包括一些編輯,以避免太多可以壓倒性的內容)並仍然有這些引用。現在的方式,如果這些鏈接發生任何事情,你的答案將是無用的。 – Masoud