Reputation: 1120
Helo,
i am trying to load custom config into my AppBundle. Unluckily I am getting:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException] There is no extension able to load the configuration for "app" (in /var/www
/dev.investmentopportunities.pl/src/AppBundle/DependencyInjection/../Resour ces/config/general.yml). Looked for namespace "app", found none
There are several similar topics relating to this error. I have looked at them but can't find any solution which would resolve this issue.
My configuration file looks like this:
<?php
namespace AppBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('app');
$rootNode
->children()
->arrayNode('tags')
->prototype('array')
->children()
->scalarNode('name')->isRequired()->end()
->scalarNode('role')->isRequired()->end()
->scalarNode('priority')->isRequired()->end()
->scalarNode('label')->isRequired()->end()
->end()
->end();
return $treeBuilder;
}
}
and general.yml:
app:
tags:
Accepted:
name: "Accepted"
role: "ROLE_ACCEPTTAG"
priority: "3"
label: "label label-info"
Booked:
name: "Booked"
role: "ROLE_ACCOUNTANT"
priority: "3"
label: "label label-info"
Finalized:
name: "Booked"
role: "ROLE_ACCEPTDOC"
priority: "1"
label: "label label-success"
AppExtension.php:
<?php
namespace AppBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\Validator\Tests\Fixtures\Entity;
/**
* This is the class that loads and manages your bundle configuration
*/
class AppExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$container->setParameter('app', $config['app']);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('general.yml'); # another file of yours
}
}
Upvotes: 2
Views: 3692
Reputation: 1715
TL;DR: You should not load your general.yml
file in the extension.
Defining a configuration for a bundle is about how the bundle will handle configuration, understand the configuration coming from config.yml
.
So you should import your general.yml
file in the config.yml
and it should work.
Note: Loaders are from Symfony\Component\DependencyInjection\Loader
namespace, they are for dependency injection, to allow a bundle to define services, mostly used by third-party bundles.
Upvotes: 1