如何在Symfony2项目的prod环境中启用调试工具栏?

Mat*_*ira 5 toolbar symfony

我有一个现有项目,只是想知道哪些文件以及我应该更改什么以使prod环境中的调试工具栏可见

Mat*_*teo 6

您应该在更改AppKernel.php文件,以便能够在PROD环境还捆绑,改变从移动路径routing_dev.ymlrouting.yml捆绑定义路线。然后在config.ymlalso中添加配置。

例如:

AppKernel.php

        // Move this outside the if statement
        $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
        $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();

    if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
        $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
        $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
    }
Run Code Online (Sandbox Code Playgroud)

routing.yml

#add this

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler
Run Code Online (Sandbox Code Playgroud)

config.yml

web_profiler:
    toolbar: true
Run Code Online (Sandbox Code Playgroud)

希望这有帮助