在 SYMFONY3 中,我在代码中大量使用了VarDumper 组件的 dump(...) 函数,该函数与DebugBundle Configuration ("debug")一起使用。
一旦您转到生产设置dump(...)
,代码中的所有内容都会成为问题并引发错误,因为在 [project]\app\AppKernel.php 中,设置如下所示:
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [...];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
...
}
return $bundles;
}
.... other functions...
}
Symfony\Bundle\DebugBundle\DebugBundle()
仅适用于“开发”环境。我可以将它添加到“prod”环境中,但出于明显的性能原因,它并不意味着那样。
这意味着必须删除(或注释)dump(...)
代码中的所有内容。我有很多,所以我想知道是否有关于该特定主题的建议,以顺利从 "dev" 移动到 "prod" 。