fix: support loading both .env and .env.example with reliable env parser and APP_ENV support

This commit is contained in:
2026-09-08 13:26:16 +02:00
parent f22417e6e3
commit ec233f3f9c
4 changed files with 91 additions and 36 deletions
+8 -13
View File
@@ -9,23 +9,19 @@
* - OP DE DEV OMGEVING: $environment = 'development'; (Rood met 'Development' + radar ping)
* - OP DE MAIN OMGEVING: $environment = 'live'; (Groen met 'Live' + radar ping)
*
* U kunt de waarde hieronder aanpassen, of instellen via APP_ENV in .env.
* U kunt dit hieronder aanpassen, of instellen via APP_ENV in .env / .env.example!
*/
// Bepaal de omgeving: 'development' of 'live' (of 'main')
$environment = 'development'; // <-- ZET DIT OP DE MAIN SERVER OP 'live'
require_once __DIR__ . '/../config/config.php';
// Optionele fallback als het in .env gedefinieerd is
if (getenv('APP_ENV')) {
$envVal = strtolower(trim(getenv('APP_ENV')));
if (in_array($envVal, ['live', 'production', 'prod', 'main'])) {
$environment = 'live';
} elseif (in_array($envVal, ['dev', 'development', 'staging', 'test'])) {
$environment = 'development';
}
// Standaard waarde (wordt overschreven als APP_ENV in .env staat)
$environment = defined('APP_ENV') ? APP_ENV : 'development';
if (function_exists('fociz_env') && fociz_env('APP_ENV')) {
$environment = fociz_env('APP_ENV');
}
$isLive = in_array(strtolower($environment), ['live', 'production', 'prod', 'main']);
$isLive = in_array(strtolower(trim($environment)), ['live', 'production', 'prod', 'main']);
?>
<!-- FLASHY OMGEVINGSINDICATOR LINKS BOVENIN -->
@@ -66,4 +62,3 @@ $isLive = in_array(strtolower($environment), ['live', 'production', 'prod', 'mai
</div>
<?php endif; ?>
</div>