A parameters.yml per bundle, symfony2

Maxim Geerinck

I was wondering if it's possible to defined a parameters.yml file for every bundle or only for the bundles that need it and load those.

I have searched a lot but i can't find such solution.

Thomas Potaire

You should clarify a bit; you want every single bundles to automatically include a parameters.yml file? I am afraid you would need to modify Symfony's DI core. There is an easy alternative though.

If you create your own bundle with some DependencyInjection then you can add $loader->load('parameters.yml'); in the bundle's extension class.

The extension class should be located in YourBundle/DependencyInjection/YourBundleExtension.php.

The class should look like the following

class YourBundleExtension extends Extension
{
    /**
     * {@inheritDoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.yml');
        $loader->load('parameters.yml'); // Adding the parameters file
    }
}

So in this case the parameters.yml file would be in YourBundle/Resources/config/parameters.yml.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Symfony2 get parameters.yml in entity, special case

From Dev

Symfony2: how to read parameters array in config.yml

From Dev

PHPUnit symfony2 faking parameters.yml

From Dev

PHPUnit symfony2 faking parameters.yml

From Dev

Number index in parameters.yml corrupted Symfony2

From Dev

Difference between parameters.yml and config.yml in Symfony2

From Dev

Symfony2 get to the access_control parameters located in the security.yml

From Dev

How can i send parameters to validators.lang.yml in symfony2 validator engine?

From Dev

Possible to modify / write to a custom parameters.yml file in symfony2?

From Dev

Symfony2 - where are all the places where the 'secret' key (parameters.yml) is used?

From Dev

Oracle database error in symfony2 (doctrine). Is parameters.yml setup correctly?

From Dev

Symfony yml parameters into doctrine yml mapping

From Dev

Symfony yml parameters into doctrine yml mapping

From Dev

yml pluralization symfony2

From Dev

Overload a bundle with Symfony2

From Dev

Symfony2 - Bundle with AngularJS

From Dev

Symfony2 Routing parameters

From Dev

Symfony2 predefined parameters

From Dev

Symfony2 cache and parameters

From Dev

Symfony2 test parameters

From Dev

QueryBuilder Symfony2 Parameters

From Dev

Symfony2 predefined parameters

From Dev

Symfony2 JMSSerializerBundle expose property in YML

From Dev

javascript translation yml symfony2

From Dev

Symfony2 - Using yml for FOSOAuthServerBundle

From Dev

Symfony2 JMSSerializerBundle expose property in YML

From Dev

Symfony2 REST bundle : Filter Parameter

From Dev

Symfony2 Composer Bundle Namespace

From Dev

Symfony2 bundle and Travis-CI

Related Related

HotTag

Archive