Symfony 服务器在扩展 FOSUserBundle 的默认模板 layout.html.twig 时崩溃 [英] Symfony Server crashes when extending FOSUserBundle's default template layout.html.twig

查看:19
本文介绍了Symfony 服务器在扩展 FOSUserBundle 的默认模板 layout.html.twig 时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 FOSUserBundle 运行基本用户登录.我正在使用 Symfony 3.0.6.

I am trying to get the basic user login running from the FOSUserBundle. I am using Symfony 3.0.6.

我按照说明设置了 FOSUserBundle 中的所有内容:https://symfony.com/doc/master/bundles/FOSUserBundle/index.html

I followed the description to setup everything from the FOSUserBundle: https://symfony.com/doc/master/bundles/FOSUserBundle/index.html

DB 已启动并运行一切似乎都很好,除了我无法弄清楚如何从 FOSUserBundle 覆盖 layout.html.twig.我遵循了这个描述来实现这一点:https://symfony.com/doc/master/bundles/FOSUserBundle/overriding_templates.html

DB is up and running everything seems fine except I cant figure out how to override the layout.html.twig from the FOSUserBundle. I followed this description for achieving that: https://symfony.com/doc/master/bundles/FOSUserBundle/overriding_templates.html

我现在在文件夹Resources/FOSUserBundle/views"中有一个文件layout.html.twig",其内容与上面提供的最后一个链接中的内容相同.这会导致以下错误:

I now have a file "layout.html.twig" in the folder "Resources/FOSUserBundle/views" with the content being the same as in the last link provided above. This leads to the following error:

找不到模板layout.html.twig"(调查:[somePathInfo]) 在第 1 行的 FOSUserBundle::layout.html.twig 中.

Unable to find template "layout.html.twig" (looked into: [somePathInfo]) in FOSUserBundle::layout.html.twig at line 1.

现在我将layout.html.twig"模板中的第一行改为

Now I changed the first line in the "layout.html.twig" Template to be

{% extends 'FOSUserBundle::layout.html.twig' %}

这会导致 symfony 服务器崩溃

And this then leads to the symfony server to crash stating

>php bin/console server:run -v                                                                                                                       
 [OK] Server running on http://127.0.0.1:8000                                                                           
 // Quit the server with CONTROL-C.
  RUN  "C:xamppphpphp.exe" "-S" "127.0.0.1:8000" "[PATH]myProjectvendorsymfonysymfonysrcSymfonyBundleFrameworkBundleResourcesconfig
outer_dev.php"
  RES  -1073741571 Command did not run successfully
 [ERROR] Built-in server terminated unexpectedly.

我被困在这里...任何想法都非常受欢迎.

I am stuck here... Any ideas are very welcome.

由 composer 安装的 FOSUserBundle(我通过当前的 PHP-Storm 插件使用)安装在路径:

The FOSUserBundle installed by the composer (which I use through the current PHP-Storm plugin) is installed at the path:

[projectPath]vendorfriendsofsymfonyuser-bundleResourcesviewslayout.html.twig

在文档中,总是只提到FOSUserBundle",我不知道如何确定该映射是否适合我项目中的路径.对此问题的任何提示也非常受欢迎.

In the docu however allways "FOSUserBundle" only is mentioned and I don't know how to figure out if that mapping fits to the path in my project. Any hints for this issue are very wellcome as well.

推荐答案

当您覆盖标准 FOSUser 布局时,您需要将布局放入 app/Resources/FOSUserBundle/views/layout.html.twig.太好了,你做到了.它只是一个布局,它不应该扩展标准 FOSUser 布局,所以删除行 {% extends 'FOSUserBundle::layout.html.twig' %}.但通常开发人员会制作一个基本布局,在我的情况下是 appResourcesviewsase.html.twig,所以如果我想覆盖 fosuser 布局,我将在 app/Resources/FOSUserBundle/views/layout.html.twig 类似这样的

When you override standart FOSUser layout you need to place your layout into app/Resources/FOSUserBundle/views/layout.html.twig. great, you did this. it's just a layout, it should not extend standart FOSUser layout, so remove line {% extends 'FOSUserBundle::layout.html.twig' %}. But usually developers make one base layout, in my case it is appResourcesviewsase.html.twig, so if I want to override fosuser layout I will have in app/Resources/FOSUserBundle/views/layout.html.twig something like this

{% extends 'base.html.twig' %}

{% block title %}User Management{% endblock %}

{% block content %}
    {% block fos_user_content %}{% endblock %}
{% endblock %}

在第一行中,您扩展了基本布局而不是 FOSUser.您可能不会扩展某些东西,也许您对此模板有单独的完整布局.

In first line you extend your base layout not FOSUser. You may not extend something, maybe you have separate complete layout for this template.

这篇关于Symfony 服务器在扩展 FOSUserBundle 的默认模板 layout.html.twig 时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆