没有扩展程序可以加载"公司"

时间:2016-12-06 17:04:01

标签: configuration symfony

错误是这种配置的结果,我无法找出我错在哪里。

这是捆绑

<?php
namespace Company;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class CompanyBundle extends Bundle
{

}

这是配置

<?php
// In src/Company/DependencyInjection
namespace Company\DependencyInjection;

use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

class Configuration implements ConfigurationInterface {

    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();

        $rootNode = $treeBuilder->root('company');

        $rootNode
            ->children()
                ->arrayNode('login')
                    ->children()
                        ->integerNode('login_attempts')->defaultValue(0)->end()
                    ->end()
                ->end() // login
            ->end();

        return $treeBuilder;
    }
}

然后我的扩展

<?php
// In src/Company/DependencyInjection

namespace Company\DependencyInjection;

use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;

class CompanyExtension extends Extension{

    public function load(array $configs, ContainerBuilder $container){ 

        $configuration = new Configuration();

        $config = $this->processConfiguration($configuration, $configs);

        $loader = new YamlFileLoader(
                $container,
                new FileLocator(__DIR__.'/../Resources/config')
                );

        $loader->load('config.yaml');

    }
}

至少我的配置文件

# In src/Company/Resources/config/config.yaml
company:
    login:
        login_attempts: 3

错误是

  

YamlFileLoader.php第431行中的InvalidArgumentException:   没有扩展程序可以加载&#34;公司&#34; (在/home/wwwcompany/company/src/Company/DependencyInjection/../Resources/config/config.yaml)。寻找命名空间&#34;公司&#34;,找不到

有什么想法吗?

由于

0 个答案:

没有答案