Php 登录时缺少symfony工具栏
我在上浏览了symfony博客教程,并希望将其扩展到需要身份验证。我松散地遵循了这一点,创建了一个新的捆绑包(我想稍后将其提取到一个公共区域),一切正常。唯一的问题是,在登录页面上,它没有显示symfony工具栏(它在其他任何地方都会显示),但页面的其余部分会按我的预期显示 有什么想法吗?提前谢谢 My login.html.twig:Php 登录时缺少symfony工具栏,php,symfony,Php,Symfony,我在上浏览了symfony博客教程,并希望将其扩展到需要身份验证。我松散地遵循了这一点,创建了一个新的捆绑包(我想稍后将其提取到一个公共区域),一切正常。唯一的问题是,在登录页面上,它没有显示symfony工具栏(它在其他任何地方都会显示),但页面的其余部分会按我的预期显示 有什么想法吗?提前谢谢 My login.html.twig: {% extends '::base.html.twig' %} {% block title %}Please Login{% endblock %} {
{% extends '::base.html.twig' %}
{% block title %}Please Login{% endblock %}
{% block body %}
{% if error %}
<div class="error-message">{{ error.message }}</div>
{% endif %}
<form action="{{ path('login_check') }}" method="post">
<label for="username">E-mail address:</label>
<input type="text" id="username" name="_username" value="{{ last_username }}"/>
<label for="password">Password:</label>
<input type="password" id="password" name="_password"/>
{#
If you want to control the URL the user
is redirected to on success (more details below)
<input type="hidden" name="_target_path" value="/account" />
#}
<button type="submit">login</button>
</form>
{% endblock %}
<!-- app/Resources/views/base.html.twig -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"
; charset=utf-8" />
<title>{% block title %}symblog{% endblock %} - symblog</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
{% block stylesheets %}
<link href='http://fonts.googleapis.com/css?family=Irish+Grover' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=La+Belle+Aurore' rel='stylesheet' type='text/css'>
<link href="{{ asset('css/screen.css') }}" type="text/css" rel="stylesheet"/>
{% endblock %}
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}"/>
</head>
<body>
<section id="wrapper">
<header id="header">
<div class="top">
{% block navigation %}
<nav>
<ul class="navigation">
<li><a href="{{ path('BloggerBlogBundle_homepage') }}">Home</a></li>
<li><a href="{{ path('BloggerBlogBundle_about') }}">About</a></li>
<li><a href="{{ path('BloggerBlogBundle_contact') }}">Contact</a></li>
{% if app.user %}
<li><a href="{{ path('logout') }}">Logout {{ app.user.username }}</a></li>
{% endif %}
</ul>
</nav>
{% endblock %}
</div>
<h2>{% block blog_title %}<a href="{{ path('BloggerBlogBundle_homepage') }}">symblog</a>{% endblock %}</h2>
<h3>{% block blog_tagline %}<a href="{{ path('BloggerBlogBundle_homepage') }}">creating a blog in
Symfony2</a>{% endblock %}</h3>
</header>
<section class="main-col">
{% block body %}{% endblock %}
</section>
<aside class="sidebar">
{% block sidebar %}{% endblock %}
</aside>
<div id="footer">
{% block footer %}
Symfony2 blog tutorial - created by <a href="https://github.com/dsyph3r">dsyph3r</a>
{% endblock %}
</div>
</section>
{% block javascripts %}{% endblock %}
</body>
</html>
{%extends'::base.html.twig%}
{%block title%}请登录{%endblock%}
{%block body%}
{%if错误%}
{{error.message}}
{%endif%}
电子邮件地址:
密码:
{#
如果要控制用户的URL
成功时重定向到(更多详细信息如下)
#}
登录
{%endblock%}
My::base.html.twig:
{% extends '::base.html.twig' %}
{% block title %}Please Login{% endblock %}
{% block body %}
{% if error %}
<div class="error-message">{{ error.message }}</div>
{% endif %}
<form action="{{ path('login_check') }}" method="post">
<label for="username">E-mail address:</label>
<input type="text" id="username" name="_username" value="{{ last_username }}"/>
<label for="password">Password:</label>
<input type="password" id="password" name="_password"/>
{#
If you want to control the URL the user
is redirected to on success (more details below)
<input type="hidden" name="_target_path" value="/account" />
#}
<button type="submit">login</button>
</form>
{% endblock %}
<!-- app/Resources/views/base.html.twig -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"
; charset=utf-8" />
<title>{% block title %}symblog{% endblock %} - symblog</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
{% block stylesheets %}
<link href='http://fonts.googleapis.com/css?family=Irish+Grover' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=La+Belle+Aurore' rel='stylesheet' type='text/css'>
<link href="{{ asset('css/screen.css') }}" type="text/css" rel="stylesheet"/>
{% endblock %}
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}"/>
</head>
<body>
<section id="wrapper">
<header id="header">
<div class="top">
{% block navigation %}
<nav>
<ul class="navigation">
<li><a href="{{ path('BloggerBlogBundle_homepage') }}">Home</a></li>
<li><a href="{{ path('BloggerBlogBundle_about') }}">About</a></li>
<li><a href="{{ path('BloggerBlogBundle_contact') }}">Contact</a></li>
{% if app.user %}
<li><a href="{{ path('logout') }}">Logout {{ app.user.username }}</a></li>
{% endif %}
</ul>
</nav>
{% endblock %}
</div>
<h2>{% block blog_title %}<a href="{{ path('BloggerBlogBundle_homepage') }}">symblog</a>{% endblock %}</h2>
<h3>{% block blog_tagline %}<a href="{{ path('BloggerBlogBundle_homepage') }}">creating a blog in
Symfony2</a>{% endblock %}</h3>
</header>
<section class="main-col">
{% block body %}{% endblock %}
</section>
<aside class="sidebar">
{% block sidebar %}{% endblock %}
</aside>
<div id="footer">
{% block footer %}
Symfony2 blog tutorial - created by <a href="https://github.com/dsyph3r">dsyph3r</a>
{% endblock %}
</div>
</section>
{% block javascripts %}{% endblock %}
</body>
</html>
编辑:我找到了答案。。。在访问控制下查看
没有任何东西被切断。我听说这是因为工具栏没有在access下正确设置,但我不完全确定如何设置。这是我的保安。yml:
security:
encoders:
Database\UserBundle\Entity\User:
algorithm: sha1
encode_as_base64: false
iterations: 1
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
administrators:
entity: { class: DatabaseUserBundle:User, property: email }
firewalls:
login_firewall:
pattern: ^/login$
anonymous: ~
secured_area:
pattern: ^/
anonymous: ~
form_login:
login_path: login
check_path: login_check
always_use_default_target_path: true
default_target_path: /
logout:
path: /logout
target: /
access_control:
- { path: /_wdt/.*, role: IS_AUTHENTICATED_ANONYMOUSLY } ### These 2 lines needed
- { path: /_profiler/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }### These 2 lines needed
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: ROLE_USER }
除非生成完整的html页面,否则滚动条不会显示。在浏览器上执行control-u。我希望你会看到一些html,然后可能是一条错误消息或一些被切断的东西。这将有希望指出问题所在。没有任何东西被切断。我听说这是因为工具栏没有在access下正确设置,但我不完全确定如何设置。这是我的保安。好的,我在网上找到了答案。访问控制需要:访问控制:-{path:/\uwdt/*,角色:通过身份验证的\u匿名}-{path:/\u profiler/*,角色:通过身份验证的\u匿名}-{path:^/login,角色:通过身份验证的\u匿名}-{path:^/,角色:用户}