php app/console config:dump-reference
时,我会收到以下错误消息:
[Symfony\Component\Config\Exception\FileLoaderLoadException] 没有扩展能够加载“loew_tag”(在somePath/blog/app/config/../../src/Loew/TagBundle/Resources/config/config.yml中)。查找命名空间“loew_tag”,在somePath/blog/app/config/../../src/Loew/TagBundle/Resources/config/config.yml中找到“…”(正在从“somePath/blog/app/config/config.yml”导入)。
和
我在“blog bundle”内工作,尝试访问“tag bundle”的配置数据。[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
没有扩展能够加载“loew_tag”(在/home/somePath/blog/app/config/../../src/Loew/TagBundle/Resources/config/config.yml中)。查找命名空间“loew_tag”,在“framework”、“security”、“twig”、“monolog”、“swiftmailer”、“assetic”、“doctrine”、“sensio_framework_extra”、“blog”、“fos_user”、“debug”、“web_profiler”、“sensio_distribution”中找到。
我的“app/config/config.yml”顶部:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: ../../src/Loew/TagBundle/Resources/config/services.yml }
- { resource: ../../src/Loew/TagBundle/Resources/config/config.yml }
LoewTagExtension.php:
<?php
// Loew/TagBundle/DependencyInjection/LoewTagExtension.php
namespace Loew\TagBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
class LoewTagExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
//$container->setParameter('food_entities', $config['food_entities']);
$container->setParameter('split_match', $config['split_match']);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('config.yml');
$loader->load('services.yml');
}
}
config.yml:
loew_tag:
# food_entities:
# - "BlogBundle:Article"
# - "BlogBundle:Comment"
split_match: "/[^0-9a-zA-ZöÖüÜäÄß]/"
Configuration.php:
<?php
// Loew/TagBundle/DependencyInjection/Configuration.php
namespace Loew\TagBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('loew_tag');
$rootNode
->children()
->scalarNode('split_match')->end()
// ->arrayNode('food_entities')
// ->prototype('scalar')->end()
->end();
return $treeBuilder;
}
}
为了尽可能保持简洁,所有文件中有关节点food_entities
的条目都被注释掉了。
我注意到,类似的问题已经被问过并且相关的问题已经得到解决,但是我无法将这些解决方案应用到这个问题上。
您有什么想法吗?我错过了什么吗?
app.php
中是否注册了该 bundle?另外,执行php app/console config:dump-reference
命令会输出什么内容? - ferdynator/app/AppKernel.php
:是的,该bundle在那里注册了:new Loew\TagBundle\TagBundle(),
控制台命令导致上述错误消息。 - dansrc\VendorName\BundleName
、src\Acme\HelloBundle
或src\Loew\TagBundle
这样的结构需要将扩展类的命名为AcmeHelloExtension
和LoewTagExtension
。 难道我理解错了,供应商名称不应该是扩展类名的一部分吗?无论如何,感谢您的提示! - dan