raspisms/descartes/load-environment.php

58 lines
1.4 KiB
PHP
Raw Normal View History

2019-10-29 14:57:13 +01:00
<?php
2019-10-29 18:33:30 +01:00
namespace descartes;
function define_array ($array)
{
foreach ($array as $key => $value)
{
define(mb_strtoupper($key), $value);
}
}
2019-10-29 14:57:13 +01:00
function load_env ()
{
2019-10-29 18:33:30 +01:00
### DESCARTES ENV ###
2019-10-29 14:57:13 +01:00
$environment = [];
$env = [];
2019-10-29 18:33:30 +01:00
2019-10-29 14:57:13 +01:00
require_once(__DIR__ . '/env.php');
$environment = array_merge($environment, $env);
//Load descartes override env
if (file_exists(__DIR__ . '/../env.descartes.php'))
{
require_once(__DIR__ . '/../env.descartes.php');
$environment = array_merge($environment, $env);
}
2019-10-29 18:33:30 +01:00
//Define all Descartes constants
define_array($environment);
### GLOBAL ENV ###
$environment = [];
$env = [];
2019-10-29 14:57:13 +01:00
if (file_exists(__DIR__ . '/../env.php'))
{
require_once(__DIR__ . '/../env.php');
$environment = array_merge($environment, $env);
}
2019-10-29 18:33:30 +01:00
define_array($environment);
2019-10-29 14:57:13 +01:00
2019-10-29 18:33:30 +01:00
### SPECIFIC ENV ###
2019-10-29 14:57:13 +01:00
$environment = [];
$env = [];
if (defined('ENV') && file_exists(__DIR__ . '/../env.' . ENV . '.php'))
{
require_once(__DIR__ . '/../env.' . ENV . '.php');
$environment = array_merge($environment, $env);
}
2019-10-29 18:33:30 +01:00
define_array($environment);
2019-10-29 14:57:13 +01:00
}
load_env();