【问题标题】:Symfony 3 - WebProfiler is turning on on my PROD envSymfony 3 - WebProfiler 正在打开我的 PROD 环境
【发布时间】:2016-12-25 10:08:12
【问题描述】:

我在我的 PROD 环境中加载了所有文件,从 /var/cache 目录中删除了所有文件和子目录并得到了空白屏幕。

添加后

ini_set("error_reporting", E_ALL);
ini_set("display_errors", "1");

app.php 文件,我得到了这个错误:

致命错误:未捕获的异常 'Symfony\Component\DependencyInjection\Exception\InvalidArgumentException' 带有消息“没有扩展能够加载“web_profiler”的配置

谁能告诉我为什么网络分析器甚至在 PROD 环境中执行?我认为它应该只用于 TESTDEV。由于这个错误,我什至无法清除本地服务器上的 PROD 缓存。

哦,在app.php 文件中我得到了$kernel = new AppKernel('prod', false);,所以不应该使用网络分析器...

更新

AppKernel.php

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),

            new JavierEguiluz\Bundle\EasyAdminBundle\EasyAdminBundle(),
            new Ivory\CKEditorBundle\IvoryCKEditorBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new Vich\UploaderBundle\VichUploaderBundle(),

            new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),

            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
            new JMS\AopBundle\JMSAopBundle(),
            new JMS\TranslationBundle\JMSTranslationBundle(),

            // my bundles here
        ];

        if(in_array($this->getEnvironment(), ['dev', 'test'], true)) {
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

    public function getRootDir()
    {
        return __DIR__;
    }

    public function getCacheDir()
    {
        return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
    }

    public function getLogDir()
    {
        return dirname(__DIR__).'/var/logs';
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}

【问题讨论】:

  • 您可以粘贴 appKernel 类和 config.yml 文件的内容 - 如果有的话,在删除脆弱数据之后?
  • 您很可能在我们的 AppKernel 类和/或您的 config_x.yml 文件中遇到问题。介意展示这些吗?
  • AFAIK,不必执行 Profiler,但在 config.yml 中的“web_profiler”节点下有一些配置 Symfony 无法分配给有效的扩展。如果您不需要分析器,请尝试从配置文件中删除该配置块。
  • profiler 配置文件应该从 config_dev.yml 加载(在某些情况下,您可能在其他环境中需要这个),但肯定不能将它放在 config_prod.yml 或 config.yml 中
  • @RafalKozlowski 我已经更新了我的问题。

标签: php symfony


【解决方案1】:

好的,我发现我在config_prod.yml 中确实使用了web_profiler 关键字。这就是问题所在……我现在很生气:D。

【讨论】:

    猜你喜欢
    • 2019-10-08
    • 2018-09-23
    • 1970-01-01
    • 1970-01-01
    • 2013-12-06
    • 2019-07-31
    • 2019-10-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多