我很新,所以Symfony2想要创建一个名为“dp”的新环境。但由于某种原因,我一直都会遇到错误。
FileLoaderLoadException: Cannot import resource "/a/b/c/d/e/app/config/config_dev.yml" from "/a/b/c/d/e/app/config/config_dp.yml".
InvalidArgumentException: There is no extension able to load the configuration for "web_profiler" (in /a/b/c/d/e/app/config/config_dev.yml). Looked for namespace "web_profiler", found "framework", "security", "twig", "monolog", "swiftmailer", "doctrine", "assetic", "sensio_framework_extra", "jms_security_extra", "smarty", "bela_meter", "bela_invoice", "bela_util"
我关注了Symfony2 documentation steps app / config / config_dp.yml的内容是
imports:
- { resource: config_dev.yml }
web / app_dp.php包含:
$kernel = new AppKernel('dp', true);
$kernel->loadClassCache();
$kernel->handle(Request::createFromGlobals())->send();
我该如何解决这个问题? config_dev.yml环境完美无瑕。
答案 0 :(得分:66)
默认情况下,WebProfilerBundle
仅在dev
和test
环境中加载。在AppKernel
课程中找到此代码段:
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
// ...
}
并将新环境名称附加到数组中:
array('dev', 'test', 'dp')
答案 1 :(得分:0)
在Symfony 4中非常简单。只需将新环境添加到bundles文件中即可。
打开config / bundles.php
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true]
成为
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'YOUR_NEW_ENV' => true]