php 无法在 Symfony 3 中找到模板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44476659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:59:27  来源:igfitidea点击:

Unable to find template in Symfony 3

phpsymfonytemplatesbundle

提问by N.Jourdan

I know that there are a lot of subject like that however I didn't find the solution

我知道有很多这样的主题但是我没有找到解决方案

I have this issue

我有这个问题

Unable to find template "CoreBundle:index.html.twig" (looked into: /var/www/html/MyProject/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).

无法找到模板“CoreBundle:index.html.twig”(查看:/var/www/html/MyProject/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form)。

This is the architecture enter image description hereThis is my controller

这是架构 在此处输入图片说明这是我的控制器

<?php

namespace CoreBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class DefaultController extends Controller
{
    /**
     * @Route("/", name="index")
     */
    public function indexAction(Request $request)
    {
        return $this->render('CoreBundle:index.html.twig');
    }

    /**
     * @Route("/ma-personnalite", name="ma-personnalite")
     */
    public function mapersonnaliteAction(Request $request)
    {
        return $this->render('CoreBundle:ma_personnalite.html.twig');
    }

    /**
     * @Route("/cv", name="cv")
     */
    public function cvAction(Request $request)
    {
        return $this->render('CoreBundle:cv.html.twig');
    }

    /**
     * @Route("/scolaires", name="scolaires")
     */
    public function scolairesAction(Request $request)
    {
        return $this->render('CoreBundle:scolaires.html.twig');
    }

    /**
     * @Route("/extra-scolaires", name="extra-scolaires")
     */
    public function extrascolairesAction(Request $request)
    {
        return $this->render('CoreBundle:extra_scolaires.html.twig');
    }

    /**
     * @Route("/contact", name="contact")
     */
    public function contactAction(Request $request)
    {
        return $this->render('CoreBundle:contact.html.twig');
    }
}

This is the config.yml

这是 config.yml

#app/config/routing.yml
core:
    resource: "@CoreBundle/Controller/"
    type:     annotation
    prefix:   /

Thanks for your time

谢谢你的时间

回答by Deadpool

According to the Symfony 3 Docsit's better to use slashes and to not use "Bundle" word.

根据Symfony 3 Docs最好使用斜杠而不是使用“捆绑”一词。

So, we have as example:

所以,我们有这样的例子:

return $this->render('@BloggerBlog/Default/index.html.twig');

回答by Alessandro Minoccheri

try to change this:

尝试改变这一点:

return $this->render('CoreBundle:index.html.twig');

to this:

对此:

return $this->render('CoreBundle::index.html.twig');

The difference is to use ::instead of :

区别在于使用::而不是:

回答by Dimitri Lukashuk

This helped me in my case: @Core/index.html.twig

在我的情况下,这对我有帮助: @Core/index.html.twig