doutong2132 2016-01-15 11:17
浏览 102
已采纳

始终在开发模式下显示工具栏

I want to always display the toolbar in dev mode, not only on errors. I have the following method:

/**
 * @Route("/", name="homepage")
 */
public function indexAction(Request $request) : JsonResponse
{
    return new JsonResponse($param);
}

that I run to test the toolbar. This generates an error of course because $param and the toolbar appears. But when I use return new JsonResponse('aaa'); everything works and the toolbar does not appear.

How to make the toolbar appread even without errors?

config:

framework:
    templating:
        engines: ['twig']
    router:
        resource: "%kernel.root_dir%/config/dev/routing.yml"
        strict_requirements: true
    profiler: { only_exceptions: false }

web_profiler:
    toolbar: true
    intercept_redirects: true

AppKernel:

if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
            $bundles[] = new Symfony\Bundle\TwigBundle\TwigBundle();
}
  • 写回答

1条回答 默认 最新

  • douqi2804 2016-01-15 12:17
    关注

    Symfony injects the toolbar only in certain conditions, and only if the response is an html response. See the WebDebugToolbarListener to learn how it's done. The listener looks for the </body> tag and injects the toolbar code before it.

    If the listener injected the toolbar into a json response, it would make the response invalid.

    You can still access the profile though, as the profiler link is included in the X-Debug-Token-Link header of the response. You can also find the profiler unique identifier in the X-Debug-Token header.

    Note that the X-Debug-Token-Link header was introduced in Symfony 2.4. Before you could only access the token.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?