簡體   English   中英

無法在Symfony 3中找到模板

[英]Unable to find template in Symfony 3

我知道有很多這樣的主題但是我沒有找到解決方案

我有這個問題

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

這是架構 在此輸入圖像描述 這是我的控制器

<?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');

試着改變這個:

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

對此:

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

不同的是使用::而不是:

在我的案例中,這對我有幫助: @Core/index.html.twig

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM