某些路线缺少Symfony开发工具栏
在尝试了解Symfony的过程中,我一直在为路由器/控制器做一些演练,这些演练都在运行,但其中一个我不再在开发环境中使用Symfony工具栏: 这些都可以工作,并且开发工具栏也存在:某些路线缺少Symfony开发工具栏,symfony,controller,url-routing,Symfony,Controller,Url Routing,在尝试了解Symfony的过程中,我一直在为路由器/控制器做一些演练,这些演练都在运行,但其中一个我不再在开发环境中使用Symfony工具栏: 这些都可以工作,并且开发工具栏也存在: class DefaultController extends Controller { /** * @Route("/app/example", name="homepage") */ public function indexAction() { re
class DefaultController extends Controller
{
/**
* @Route("/app/example", name="homepage")
*/
public function indexAction()
{
return $this->render('default/index.html.twig');
}
/**
* @Route("/hello/{name}", name="hello")
*/
public function helloAction($name)
{
return $this->render('default/hello.html.twig', array(
'name' => $name
));
}
}
http://localhost/app_dev.php/app/example
http://localhost/app_dev.php/random/111
class DefaultController extends Controller
{
/**
* @Route("/app/example", name="homepage")
*/
public function indexAction()
{
return $this->render('default/index.html.twig');
}
/**
* @Route("/hello/{name}", name="hello")
*/
public function helloAction($name)
{
return $this->render('default/hello.html.twig', array(
'name' => $name
));
}
}
http://localhost/app_dev.php/hello/world
此hello world测试的路由/控制器如下所示: /app/config/routing.yml:
acme_test2:
resource: "@AcmeTest2Bundle/Resources/config/routing.yml"
prefix: /
app:
resource: @AppBundle/Controller/
type: annotation
AppBundle\Controller\DefaultController:
class DefaultController extends Controller
{
/**
* @Route("/app/example", name="homepage")
*/
public function indexAction()
{
return $this->render('default/index.html.twig');
}
/**
* @Route("/hello/{name}", name="hello")
*/
public function helloAction($name)
{
return $this->render('default/hello.html.twig', array(
'name' => $name
));
}
}
确保您有:
<!DOCTYPE html>
作为生成的html中的第一行。我从我的
/app/config/routing.yml
中删除了以下代码,现在所有路线上都会出现开发工具栏:
acme_test2:
resource: "@AcmeTest2Bundle/Resources/config/routing.yml"
prefix: /
我的一些路线也出现了工具栏缺失的问题,特别是那些使用细枝模板的路线。 这是由于my.twig模板中缺少
造成的
在模板中添加
解决了这个问题,工具栏再次可见。谢谢Udan-我成功地让它工作了,尽管我必须承认我不完全确定它为什么工作(!)。我现在就发布答案-希望有人能解释它为什么有效的逻辑oP