Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony2。没有能够加载配置的扩展。自定义配置块_Php_Symfony_Configuration - Fatal编程技术网

Php Symfony2。没有能够加载配置的扩展。自定义配置块

Php Symfony2。没有能够加载配置的扩展。自定义配置块,php,symfony,configuration,Php,Symfony,Configuration,我将在symfony 2开始我的第一个项目。我使用Symfony 2.6.6 我的AppKernel.php <?php use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Config\Loader\LoaderInterface; class AppKernel extends Kernel { public function registerBundles() { $bund

我将在symfony 2开始我的第一个项目。我使用Symfony 2.6.6

我的AppKernel.php

<?php

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

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            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 FOS\UserBundle\FOSUserBundle(),
            new AppBundle\AppBundle(),
        );

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

        return $bundles;
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}
我不明白为什么我在调用应用程序/控制台时会收到此消息

  [Symfony\Component\Config\Exception\FileLoaderLoadException]    There is no extension able to load the configuration for "karmed" (in /home/vstas/data/work/karmed/app/config/config.yml). Looked for namespace "karmed", found "framework", "security", "twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "fos_user", "app", "debug", "web_profiler", "sensio_distribution" in /home/vstas/data/work/karmed/app/config/config.yml (which is being imported from "/home/vstas/data/work/karmed/app/config/config_dev.yml").  
我尝试从目录app/cache中删除所有文件

我认为问题在于配置加载顺序,因为当我尝试将AppExtension更改为

.....
class AppExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container)
    {
        print "exit";
        exit();
        $configuration = new Configuration();
.....
没有什么变化。
但是当我从config.yml中删除我的部分变量时,我可以看到我的调试消息

配置使用的不是rootnode名称,而是扩展的DI别名。因为它是AppExtension,所以它的别名是
app
。改为使用
app:
进行配置


但是,AppBundle的不可重用。它不应该使用自定义配置。只需直接使用常量(最佳做法)或服务参数(推荐做法)。

非常感谢。我想了想,但没有时间检查。我知道最佳实践,在我的项目中,我不会使用“语义配置”。这只是为了教育。:)谢谢大家!@vstas78如果此答案解决了您的问题,请
karmed:
  var: off
  [Symfony\Component\Config\Exception\FileLoaderLoadException]    There is no extension able to load the configuration for "karmed" (in /home/vstas/data/work/karmed/app/config/config.yml). Looked for namespace "karmed", found "framework", "security", "twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "fos_user", "app", "debug", "web_profiler", "sensio_distribution" in /home/vstas/data/work/karmed/app/config/config.yml (which is being imported from "/home/vstas/data/work/karmed/app/config/config_dev.yml").  
.....
class AppExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container)
    {
        print "exit";
        exit();
        $configuration = new Configuration();
.....