Skip to content
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

Environment support #39

Open
gustavohenke opened this issue Apr 2, 2015 · 6 comments
Open

Environment support #39

gustavohenke opened this issue Apr 2, 2015 · 6 comments

Comments

@gustavohenke
Copy link

Hey,
I'm a Node.js developer which needs to program an app using PHP for college! So I thought of using this config manager, which is very alike with node-config.

But I want to override a few options with environment variables, because of Heroku, for example. node-config allows me to do this via an special custom-environment-variables configuration.

What do you think of implementing something similar in your amazing project?

@hassankhan
Copy link
Owner

Hi, I was thinking of some sort of integration with phpdotenv but I'm not quite sure how. Do you have any examples of how you'd like to use it?

@gustavohenke
Copy link
Author

That's how it works with that Node module:

custom-environment-variables.yml

db:
  # For Codeship
  username: PG_USER
  password: PG_PASSWORD

  # For Heroku
  url: DATABASE_URL

Then, my db.username and db.password configs are overriden by Codeship env vars, and db.url is overriden by Heroku env vars.

@hassankhan
Copy link
Owner

This seems a bit overkill for this package, because (AFAIK) we'll have to check the value of each configuration value to see if it matches an environment variable. I hope I'm wrong and there's a better way of doing it.

@hassankhan
Copy link
Owner

Just an update, this can be done in PHP using the dotenv package - still not sure about other file formats though

@rauwebieten
Copy link

If you use php as config file, you can load env variables like this:

<?php

return [
    'some_config_parameter' => getenv('SOME_ENV_PARAMETER')
];

@devnix
Copy link

devnix commented Jan 10, 2019

It could be interesting to have something like Symfony, reading the .env file and filling variables.
For example:

db:
  driver: mariadb
  username: '%env(DB_USERNAME)%'
  password: '%env(DB_PASSWORD)%'

peter279k pushed a commit to open-source-contributions/config that referenced this issue May 8, 2021
…it/phpunit-8.0.4

Bump phpunit/phpunit from 8.0.3 to 8.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants