Set External Parameters in the Service Container not working in Yosemite

191 Views Asked by At

I am using Symfony on Mac OS X Yosemite and I want to set an environment variable to get my db information.

Since I have many projects , I need a way to separate them. I did the following:

launchctl setenv SYMFONY__MYPROJECT__DATABASE__NAME test

Then, in my project, I did the following:

doctrine:
    dbal:
        connections:
            default:
                dbname: %myproject.database.name%

When I try to run my page, I get the following error:

You have requested a non-existent parameter "myproject.database.name%

Then, I said, maybe I should use export instead of launchctl

export SYMFONY__MYPROJECT__DATABASE__NAME=test

But even after restarting, the error was the same. I am using MAMP PRO, I don't know if there can be a link with it.

Edit 1: I looked for the result of phpinfo() and php -i and the variable appears in $_ENV[]. When I debug, it really looks like the environment variables are not merged with the ones from the server... https://github.com/symfony/symfony/issues/10208

I can resolve the issue by doing what fabpot did as a fix in app_dev.php:

$_SERVER = array_merge($_SERVER, $_ENV);

but this is not really what I want, to modify app_dev.php for something that symfony should be doing.

0

There are 0 best solutions below