doumao1047 2017-03-29 09:03
浏览 12
已采纳

错误的symfony配置

I have a problem with configuration of my project and I can't see where is the mistake...

AppKernel.php ...

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new CMS\CoreBundle\CMSCoreBundle(),
        ];

app/config/routing.yml

cms_core:
    resource: "@CMSCoreBundle/Resources/config/routing.yml"
    prefix:   /

src/CMS/CoreBundle/Resourcers/config/routing.yml

cms_core_homepage:
    path:     /
    defaults: { _controller: CMSCoreBundle:Default:index }

src/CMS/CoreBundle/Resources/views/index.html.twig

{% extends "@CMSCoreBundle/template.html.twig" %}

{% block content %}
test
{% endblock %}

src/CMS/CoreBundle/Resources/views/template.html.twig

{% block content %}
Template block
{% endblock %}

And I'm getting this message

There are no registered paths for namespace "CMSCoreBundle" in CMSCoreBundle::index.html.twig at line 1.

Where is the mistake please ? Thank you guys.

  • 写回答

1条回答 默认 最新

  • dos3018 2017-03-29 10:01
    关注

    I think you have 2 ways to fix it.

    you can add your bundle to the path

    #app/config/config.yml
    twig:
        paths:
            "%kernel.root_dir%/../src/CMS/CoreBundle/Resources/views/": CMSCoreBundle
    

    Or try to extend your template like that

    {% extends "CMSCoreBundle:template.html.twig" %}
    

    I'm not 100% sure for the 2nd solution.

    Hope it may helps you

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计