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

时间:2016-09-02 09:33:27

标签: symfony toolbar

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

1 个答案:

答案 0 :(得分:4)

您应该更改AppKernel.php文件以便在prod环境中启用捆绑包,并更改从routing_dev.yml移动到routing.yml捆绑包定义路由的路由。然后在config.yml中添加配置。

例如:

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();
    }

的routing.yml

#add this

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

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

config.yml

web_profiler:
    toolbar: true

希望这个帮助