【问题标题】:How enable debugging toolbar in prod environment of a Symfony2 project?如何在 Symfony2 项目的 prod 环境中启用调试工具栏?
【发布时间】:2016-09-02 09:33:26
【问题描述】:

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

【问题讨论】:

标签: symfony toolbar


【解决方案1】:

您应该更改 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

希望有帮助

【讨论】:

  • 网站变为空白。也许该项目有一些更改的文件使得这不可能:x
  • 嗨@MatheusOliveira 检查我的更新。如果出现错误(空白页),请在日志文件 (app/logs/prod.log) 中检查异常。告诉我
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多