我知道有很多类似的主题,但我没有找到解决方案
我有这个问题
无法找到模板“CoreBundle:index.html.twig”(查看:/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
#app/config/routing.yml
core:
resource: "@CoreBundle/Controller/"
type: annotation
prefix: /
谢谢你的时间
根据Symfony 3 文档 https://symfony.com/doc/3.4/templating.html#referencing-templates-in-a-bundle最好使用斜杠,不要使用“Bundle”一词。
所以,我们有这样的例子:
return $this->render('@BloggerBlog/Default/index.html.twig');
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)