好的,在有人向我射击之前。我实际上并不想在prod模式下运行web profiler。
我刚开始从symblog教程(非常好)开始倾斜symfony。
第5节的后半部分讨论了不同的配置文件,dev和prod。
作为一项测试,我希望在prod模式下启用web Profiler,但是当我输入配置设置时:
web_profiler:
toolbar: true
intercept_redirects: false
然后清除缓存,
php app/console cache:clear --env=prod
我收到以下错误:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
There is no extension able to load the configuration for "web_profiler" (in /var/webroot/www/vhosts/wizards.co.uk
/htdocs/Symfony/app/config/config_prod.yml). Looked for namespace "web_profiler", found "framework", "security",
"twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "blogger_blog", "doctrine_migr
ations"
网络探查器是否在生产模式下无法使用,就像我试图搞砸它的白痴:)?
谢谢, 约翰
答案 0 :(得分:0)
在点击帖子之后,我意识到AppKernal中的逻辑正是这样做的:
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
答案 1 :(得分:0)
webProfilerBundle未包含在生产环境中,因此需要通过将其添加到先前的bundle数组中而不使用任何if条件来完成。
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 Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(),
new AppBundle\AppBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
然后清除'prod'环境中的缓存
php bin/console cache:clear --env=prod --no-debug
现在应该可以了!