-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Environment variables (ENV) for passing secrets to composer.json? #6081
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
IMO, a better solution is to integrate an environment feature in the credentials system only. Allowing env variables anywhere in composer.json becomes a nightmare, because it means that different values of the env variables could require invalidating the composer.lock (imagine you use the env var for the full repository URL. A different URL may have different packages) |
My thoughts exactly: env vars for credentials only is simpler and would not break too much things. Example:
SATIS_REPSAUTH="repo1.example.org:extremely:secret1\nrepo2.example.org:simple:secret2" \
composer install
# Or:
SATIS_REPSAUTH_repo1_example_org="extremely:secret1" \
SATIS_REPSAUTH_repo2_example_org="simple:secret2" \
composer install |
|
May I ask for revising this request again, seams that there are some more use-cases here where it can be useful, per example, from: https://getcomposer.org/doc/06-config.md
Thanks! |
For 1. we already have CLI flags, I don't see what an env var gains you there really, this stuff has to be in scripts anyway. For 2. the cache dir is configurable via COMPOSER_CACHE_DIR already. |
|
Actually I have the case that I've got the same packages in two totally encapsulated environments. The transfer happens manually via Git. So it would be very nice to have environment variables available provided by a .env file, for e.g. the VCS repo paths. |
I have a case where I pull in another repo into my project via composer. I have testing, staging and production branches. composer.json has to be different for each of these branches. So, currently, we have composer.json, composer-stage.json and composer-test.json all in the repository, but the only difference is one line. I am trying to figure out an easy way to consolidate them. If I could set an environment variable and then use it in composer.json that would work. Even if I could just set a variable on the command line, that would help too. Or use a global config variable. Maybe I am missing something obvious? |
I wonder if it would be useful (I ran into a use case where yes, it is) to pass repositories' credentials:
In the following
composer.json
, :Running the following command would make Composer replace
${REPO_USER}
and${REPO_PASSWD}
with the provided credentials when contacting repo.example.orgThis would avoid storing secrets into
composer.json
and would ease Continuous Integration, Dockerification, etc.My initial thought was to make environment variables interpreted in
composer.json
but according to few GitHub issues I stumbled upon, this will not happens to avoid making Composer too complex.Maybe an intermediate fix could be done for credentials (such as, supporting a special environment variable syntax for repositories' credentials)?
A workaround is to create the
auth.json
file (as per the documentation but it's less direct and writes passwords to disk.The text was updated successfully, but these errors were encountered: