Last active
April 16, 2022 10:12
-
-
Save ostark/e1c693c5fbb78d8398130891ffcbff91 to your computer and use it in GitHub Desktop.
Creates auth.json from ENV vars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example: Oauth with Github token | |
* php make-auth-json.php github-oauth.github.com GITHUB_TOKEN | |
* | |
* Example: Basic auth for private satis repo | |
* php make-auth-json.php http-basic.nova.laravel.com NOVA_USERNAME NOVA_PASSWORD | |
*/ | |
// remove script name | |
array_shift($argv); | |
$configArgs = []; | |
// Replace script arguments with ENV vars | |
foreach ($argv as $key) { | |
$configArgs[] = getenv($key) ?: $key; | |
} | |
// Pass modified arguments to 'composer config | |
shell_exec('composer config --auth ' . implode(' ', $configArgs)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment