在Symfony 3中找不到模板 [英] Unable to find template in Symfony 3

查看:114
本文介绍了在Symfony 3中找不到模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我遇到了这个问题


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

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

这是架构

这是我的控制器

This is the architecture This 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');
    }
}

这是config.yml

This is the config.yml

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

感谢您的时间

推荐答案

根据 Symfony 3 Docs 最好使用斜杠而不使用 Bundle一词。

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

因此,我们举个例子:

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

这篇关于在Symfony 3中找不到模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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