Skip to content

Instantly share code, notes, and snippets.

@helhum
Last active August 15, 2017 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helhum/eb85610a9be7c4d599bbe150dc6d8375 to your computer and use it in GitHub Desktop.
Save helhum/eb85610a9be7c4d599bbe150dc6d8375 to your computer and use it in GitHub Desktop.
Fix environment variables with `REDIRECT_` prefix
{
"autoload": {
"files": ["res/fix-env.php"]
}
}
<?php
call_user_func(function($env) {
foreach ($env as $name => $value) {
if (strpos($name, 'REDIRECT_') !== 0) {
continue;
}
$cleanedName = str_replace('REDIRECT_', '', $name);
if (!isset($_ENV[$cleanedName])) {
putenv($cleanedName . '=' . $value);
$_ENV[$cleanedName] = $value;
}
}
}, $_ENV);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment