当我运行命令时,从3.0.2更新到最新版本的Symfony后。
php bin/console cache:clear --env=prod
我现在收到以下错误:
[Symfony''Component''DependencyInjection''Exception''ServiceNotFoundException] 服务"探查器"依赖于不存在的服务 "debug.security.access.decision_manager"。
有谁知道为什么会发生这种情况,或者我可以做些什么来解决这个问题?我可以根据需要添加任何其他信息。提前谢谢!!
这个问题与我在生产环境中包括调试资源的事实有关。我正在对缓存机制进行测试,但忘记从 config.yml 和 AppKernel.php 文件中删除包含的内容。
if (in_array($this->getEnvironment(), ['dev','test','prod'], 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();
//... Extensions From Base
$bundles[] = new Doctrine'Bundle'FixturesBundle'DoctrineFixturesBundle();
}
因此,AppKernel 实例化需要将调试参数设置为 true。
$kernel = new AppKernel('prod', true);
否则,它会导致我要求解决此问题的初始问题。