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)
|
|
|
|
{
|
2019-10-30 00:17:10 +01:00
|
|
|
if (defined(mb_strtoupper($key)))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-10-29 18:33:30 +01:00
|
|
|
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
|
|
|
|
2024-02-25 11:04:45 +01:00
|
|
|
// Load descartes base env
|
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
|
|
|
|
|
|
|
### GLOBAL ENV ###
|
2024-02-25 11:04:45 +01:00
|
|
|
//Load global app env
|
2019-10-29 18:33:30 +01:00
|
|
|
$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
|
|
|
### SPECIFIC ENV ###
|
2024-02-25 11:04:45 +01:00
|
|
|
// Load specific environment env
|
2019-10-29 14:57:13 +01:00
|
|
|
$env = [];
|
2024-02-25 11:04:45 +01:00
|
|
|
if (isset($environment['ENV']) && file_exists(__DIR__ . '/../env.' . $environment['ENV'] . '.php'))
|
2019-10-29 14:57:13 +01:00
|
|
|
{
|
2024-02-25 11:04:45 +01:00
|
|
|
require_once(__DIR__ . '/../env.' . $environment['ENV'] . '.php');
|
2019-10-29 14:57:13 +01:00
|
|
|
$environment = array_merge($environment, $env);
|
|
|
|
}
|
|
|
|
|
2024-02-25 11:04:45 +01:00
|
|
|
### BUILD HTTP PWD CONSTS ###
|
|
|
|
// We compute http pwd at last minute to allow for simple overriding by user
|
|
|
|
// by simply defining custom HTTP_* (PROTOCOL, SERVER_NAME, SERVER_PORT, DIR_PATH)
|
|
|
|
$http_pwd = $environment['HTTP_PROTOCOL'] . $environment['HTTP_SERVER_NAME'] . $environment['HTTP_SERVER_PORT'] . $environment['HTTP_DIR_PATH'];
|
|
|
|
$env = [
|
|
|
|
"HTTP_PWD" => $http_pwd,
|
|
|
|
'HTTP_PWD_ASSETS' => $http_pwd . '/assets', //HTTP path of asset dir
|
|
|
|
'HTTP_PWD_IMG' => $http_pwd . '/assets' . '/img',
|
|
|
|
'HTTP_PWD_CSS' => $http_pwd . '/assets' . '/css',
|
|
|
|
'HTTP_PWD_JS' => $http_pwd . '/assets' . '/js',
|
|
|
|
'HTTP_PWD_FONT' => $http_pwd . '/assets' . '/font',
|
|
|
|
];
|
|
|
|
$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();
|