-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
BestPractices doc recommends using env vars for 'sensitive options', points to example URL, but does not provide any info for Nginx #5196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Noting what appears to be the right approach, but seems to be broken atm; BUG report at Symfony2+nginx external ENV vars aren't recognized by doctrine DB actions. fails with 'connection refused'. |
I wonder if we should consider recommending https://github.com/vlucas/phpdotenv for this like laravel does. |
👍 |
ping @javiereguiluz @weaverryan what are your thoughts on recommending (and maybe even implementing into the SE) the phpdotenv library? |
@wouterj I'm afraid I haven't used the phpdotenv library yet, so I can't say anything about it. In any case, I think this is still some weak spot in Symfony (or at least in the Symfony documentation). I'd like to know "the solution" to safely store the most sensitive configuration options (e.g. database credentials) and use them in the application. |
environment variables are used by many other frameworks for this include Laravel. They have supplemented phpdotenv by adding some coercion methods so you can force 0 and 1 to be booleans and also handling null values correctly. Environment variables are also recommended for 12 factor apps. Environment variables also integrate nicely with travis and heroku (and likely other PaaS). @beberlei is the one who pointed out this particular library to me in this post http://www.whitewashing.de/2014/10/26/symfony_all_the_things_web.html I had personally used this gem in my rails apps https://github.com/laserlemon/figaro to handle this, but both the travis and heroku gems allow you to set them for their respective services |
Quickly - I've also been thinking about dotenv lately, so personally, I'm certainly for exploring it. I don't believe using environmental variables over parameters.yml has any technical or security advantage, but they are more standard and familiar (and much easier to work with iirc when using something like Heroku). What's interesting about dotenv is that it gives an idiot-proof way of setting the environment variables if you don't understand setting them some other way. @wouterj @jrobeson how would to envision dotenv being recommended? And alternative to putting things in parameters.yml? A full replacement that's officially recommended? Thanks! |
@jrobeson you replied as I posted :) - very very good points, I'm even more in favor of dotenv as a recommendation, if not a full proposal for a parameters.yml replacement. Thanks! |
@weaverryan: I do recommend using environment variables by default, although i'm not sure about this particular library. I haven't actually looked around all that much for alternatives. I'm also using this particular program , but i'm not sure how well it would work for everyone (especially on windows) , but it's a nice supplement: http://direnv.net/ I't td be nice for them to be able to act on the same file. @weaverryan : note that phpdotenv 2.x supports json and yaml loaders as well. |
@weaverryan I've used dotenv while playing around with Laravel. It uses it as a full replacement for the Symfony Laravel, being known to use the convention over configuration rule, uses |
i rely on the SYMFONY__ variables currently and the tiny fix suggested in this bug symfony/symfony#7555 . The only real problem i have is the lack of parameter coercion |
I'm closing this as "won't fix" because we no longer recommend using the |
The Symfony "Best Practices" docs at
recommend
And point to
Following/Reading at
the docs provide an example for setting EnvVars for use when using Apache
but avoid any example sufficient and correct for nginx, stating only
The nginx/env pieces are here
But there needs to be a good nginx example -- that works -- to properly provide ENV vars so that
The text was updated successfully, but these errors were encountered: