不覆盖symfony2.6和FOSUserBundle 1.3中的模板的问题是什么 [英] What is the issue with not overriding templates in symfony2.6 and FOSUserBundle 1.3

查看:66
本文介绍了不覆盖symfony2.6和FOSUserBundle 1.3中的模板的问题是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用'cimple'选项覆盖FOSUserBundle的基本布局,将克隆路径设置为.app/Resources/FOSUserBundle/views/layout.html.twig,但是symfony2.6继续从供应商目录中呈现模板.

I'm trying to override the base layout of FOSUserBundle using the 'simple' option of making a cloned path as .app/Resources/FOSUserBundle/views/layout.html.twig , but symfony2.6 continues to render the template from inside the vendor directory.

我的作曲家需要:

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.6.*",
    "doctrine/orm": "~2.2,>=2.2.3,<2.5",
    "doctrine/dbal": "<2.5",
    "doctrine/doctrine-bundle": "~1.2",
    "twig/extensions": "~1.0",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~3.0,>=3.0.12",
    "sensio/framework-extra-bundle": "~3.0,>=3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "friendsofsymfony/user-bundle": "~1.3"
},

我检查了以下常见问题:

I've checked the following common issues:

  • 文件系统区分大小写-看起来不错
  • 具有正确的路径-似乎还可以
  • 清除缓存:手动和从应用程序/控制台清除-在这里没有问题

其他信息: -使用ubuntu-trusty-64在无业游民的实例上运行 -同步的文件夹是通过NFS

Other information: - runs on a vagrant instance with ubuntu-trusty-64 - the synced folder is through NFS

我接下来应该做什么或下一步做什么的任何想法?

Any ideas in what I should look or do next ?

推荐答案

该问题与Symfony2或FOSUserBundle无关,但与PHP缓存文件统计信息的方式有关.

The problem had mostly nothing to do with Symfony2 or FOSUserBundle, but with the way PHP caches the file stats.

要找到要加载的正确模板,标准Symfony2使用Symfony\Component\HttpKernel\Kernel->locateResource,首先检查.app\Resources目录中是否存在替代,并且如果$first参数设置为true,它将从foreach循环中返回.

To locate the right template to load, standard Symfony2 uses Symfony\Component\HttpKernel\Kernel->locateResource , by first checking if an override exists in the .app\Resources directory and if the $first parameter is set to true it returns from inside the foreach loop.

在我的配置中,PHP决定继续使用文件高速缓存,即使文件在那里,也对file_exists回答否.

In my configuration, PHP decided to keep using the filecache and answer no to file_exists even if the file was there.

要解决此问题,我的AppKernel.php会覆盖Symfony\Component\HttpKernel\Kernel类的locateResource:

To go around / fix this problem my AppKernel.php overrides the locateResource of the Symfony\Component\HttpKernel\Kernel class:

<?php
class AppKernel extends Kernel
{
    // .. other methods here

    public function locateResource($name, $dir = null, $first = true)
    {
        clearstatcache(true);
        return parent::locateResource($name, $dir, $first);
    }
}

不漂亮,但是可以.

这篇关于不覆盖symfony2.6和FOSUserBundle 1.3中的模板的问题是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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