php - 无法在 Symfony 3 中找到模板

标签 php symfony templates bundle

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

我有这个问题

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

这是架构 enter image description here 这是我的 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');
    }
}

这是config.yml

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

谢谢你的时间

最佳答案

根据Symfony 3 Docs最好使用斜线而不使用“bundle ”一词。

所以,我们举个例子:

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

关于php - 无法在 Symfony 3 中找到模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44476659/

相关文章:

php - 单击div时加载MySQL数据

php - HTML 表单数据到 SQL 数据库

php - php 会停止在 windows 二进制文件中支持 apache 吗?

symfony - 如何从 symfony 2 Controller 中删除嵌入表单中的表单字段

python - 仅在模板匹配(模板匹配)时才绘制正方形

javascript - 使用 PHP 和 Javascript 将彩信插入 MySQL 数据库

javascript - 获取输入的动态值 JQuery + Twig

Symfony2 - 功能测试 : container not injected into a Doctrine DataFixture - Call to a member function get() on a non-object

c++ - 插入跳过列表

c++ - 为什么模板只能在头文件中实现?