Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
某些路线缺少Symfony开发工具栏_Symfony_Controller_Url Routing - Fatal编程技术网

某些路线缺少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

在尝试了解Symfony的过程中,我一直在为路由器/控制器做一些演练,这些演练都在运行,但其中一个我不再在开发环境中使用Symfony工具栏:

这些都可以工作,并且开发工具栏也存在:

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