Skip to content

Instantly share code, notes, and snippets.

@pgilad
Created September 7, 2017 06:43
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 pgilad/9af010f899ffb49a11fe68ba35e7d345 to your computer and use it in GitHub Desktop.
Save pgilad/9af010f899ffb49a11fe68ba35e7d345 to your computer and use it in GitHub Desktop.
env.php
<?php
use Yosymfony\Toml\Toml;
ini_set('display_errors', false);
ini_set('display_startup_errors', true);
ini_set('newrelic.appname', 'gilad-dev');
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING);
// disable newrelic
if (function_exists('newrelic_disable_autorum')) {
newrelic_disable_autorum();
}
// disable exposing X-Powered-By
if (function_exists('header_remove')) {
header_remove('X-Powered-By');
} else {
@ini_set('expose_php', 'off');
}
// search for config files
$files = glob(__DIR__ . '/env-config/*.{json,yml,toml}', GLOB_BRACE);
return array_reduce($files, function ($config, $file) {
$extension = pathinfo($file, PATHINFO_EXTENSION);
if ($extension === 'json') {
$contents = json_decode(file_get_contents($file), true);
} elseif ($extension === 'yml') {
$contents = yaml_parse_file($file);
} elseif ($extension === 'toml') {
$contents = Toml::parse($file);
} else {
throw new Exception("Unrecognized file extension to load: $extension");
}
return array_merge($config, $contents);
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment