pierallard
pierallard

Reputation: 3371

Change default configuration file of Symfony2 project

Context

I have a simple Symfony2 project (only command line commands). This project includes an app/config.yml file, containing information used for dependency injection creation.

For example, app/config.yml contains:

github:
    token: abcdefgh

And src/Foo/Resources/config/github.yml (services files) contains:

services:
    github.client:
        class: Github\Client
        calls:
            - ['authenticate', [%github.token%, null, 'http_token']]

The file app/config.yml is loaded by Application::__construct() function.

When I run app/console mycommand, it uses the defined token.

Needs

I need to be able to run my commands using different configurations. For now, I replace manually the app/config.yml file, but it's crappy.

To do this, I thought about 2 possible solutions:

I don't know how to do one of this solution (or a third one, no matters). If it's a common behavior, can you point me some documentation or example to do something like this?

Upvotes: 1

Views: 53

Answers (1)

NathanVss
NathanVss

Reputation: 644

It is totally possible by using different environements, check out the doc : http://symfony.com/doc/current/cookbook/configuration/environments.html

Typically you will specify the environement using --env=myenv.

Upvotes: 2

Related Questions