4

I develop a little bundle, that provides tag cloud functionality. It should be easy, to include it in other Symfony projects and therefore it needs to be configurable. I discovered 3 pages:

I worked along the examples, but it's obvious, that I miss something, because I get the following error message when I use php app/console config:dump-reference:

[Symfony\Component\Config\Exception\FileLoaderLoadException] There is no extension able to load the configuration for "loew_tag" (in somePath/blog/app/config/../../src/Loew/TagBundle/Resources/config/config.yml). Looked for namespace "loew_tag", found " ... " in somePath/blog/app/config/../../src/Loew/TagBundle/Resources/config/config.yml (which is being imported from "somePath/blog/app/config/config.yml").

and

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
There is no extension able to load the configuration for "loew_tag" (in /home/somePath/blog/app/config/../../src/Loew/TagBundle/Resources/config/config.yml). Looked for namespace "loew_tag", found "framework", "security", "twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "blog", "fos_user", "debug", "web_profiler", "sensio_distribution"

I work inside a 'blog bundle' and try to access the config data for the 'tag bundle'.

Top of my '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;
    }
}

Entries for the node food_entities are commented in all files to keep it as simple as possible.

I noticed, that similar questions has been asked and the regarding problems has been solved but I cannot transfer that solutions to this issue.

Any idea, what I do miss?

8
  • Could you link to the other question? Commented Aug 13, 2015 at 15:12
  • thx for response, but unfortunately I cannot reproduce the search terms that led me to those questions. I remember, that one posted question has been solved by considering a specific naming convention. It was related to the name of a root node inside config.yml and it's mapping in the treeBuilder inside of Configuration.php and further to the naming of the extension class that has to follow the vendor / bundle schema whereby 'Bundle' is replaced by 'Extension'. It looks like that's not my issue. I will keep on searching for that questions. Commented Aug 13, 2015 at 20:14
  • 1
    Is the bundle registered in you app.php? Also what does the command php app/console config:dump-reference output? Commented Aug 27, 2015 at 10:58
  • 2
    Is your DI extension loaded? I see a mismatch between your bundle name and the extension LeowTagBundle vs TagBundle. Commented Sep 2, 2015 at 11:05
  • 1
    Yes, but the vendor should also be part of the bundle class name. See symfony.com/doc/current/cookbook/bundles/… Commented Sep 4, 2015 at 6:18

1 Answer 1

0

Finally solved this by

  • keeping naming conventions in mind, especially the part, pointed out by Jakub Zalas
  • removing entry: $loader->load('config.yml'); from the extension file.

Obviously, the config file will be loaded automatically as soon, as the service has been loaded.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.