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 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?