Created
September 7, 2017 06:43
-
-
Save pgilad/9af010f899ffb49a11fe68ba35e7d345 to your computer and use it in GitHub Desktop.
env.php
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 | |
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