某些路线缺少 Symfony 开发工具栏
Symfony development toolbar missing for some routes
在尝试弄清楚 Symfony 的过程中,我一直在为 router/controller 做一些演练,除了其中一个我不再在开发环境:
这两个都有效并且开发工具栏存在:
http://localhost/app_dev.php/app/example
http://localhost/app_dev.php/random/111
这有效,但开发工具栏消失了:
http://localhost/app_dev.php/hello/world
我不确定它是否相关,但在一天中时不时地返回错误(当我重新提交时,错误消失):
ContextErrorException in FileProfilerStorage.php line 137:
Warning: mkdir(): Permission denied`
这个hello world测试的routing/controller如下:
/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: /
我也遇到过一些路线上缺少工具栏的问题 - 特别是那些使用树枝模板的路线。
这是由于我的 .twig 模板中缺少 </body>
。
在模板中添加 </body>
解决了这个问题,工具栏再次可见。
在尝试弄清楚 Symfony 的过程中,我一直在为 router/controller 做一些演练,除了其中一个我不再在开发环境:
这两个都有效并且开发工具栏存在:
http://localhost/app_dev.php/app/example
http://localhost/app_dev.php/random/111
这有效,但开发工具栏消失了:
http://localhost/app_dev.php/hello/world
我不确定它是否相关,但在一天中时不时地返回错误(当我重新提交时,错误消失):
ContextErrorException in FileProfilerStorage.php line 137:
Warning: mkdir(): Permission denied`
这个hello world测试的routing/controller如下:
/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: /
我也遇到过一些路线上缺少工具栏的问题 - 特别是那些使用树枝模板的路线。
这是由于我的 .twig 模板中缺少 </body>
。
在模板中添加 </body>
解决了这个问题,工具栏再次可见。