我有一个现有项目,只是想知道哪些文件以及应该更改哪些内容才能使调试工具栏在产品环境中可见
最佳答案
您应该更改 AppKernel.php
文件,以便在 prod 环境中启用 bundle ,并将路由从 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();
}
路由.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
希望这有帮助
关于symfony - 如何在 Symfony2 项目的 prod 环境中启用调试工具栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39289095/