docker compose exemplified, .env integration

This commit is contained in:
Reindl David (IT-PTR-CEN2-SL10) committed 2026-10-07 18:59:58 +02:00
1 parent b1284f6fa9
commit 42ef989fb7
6 files changed
+22 -5

No files matched your search

+8 -3
View File
@@ -9,9 +9,14 @@ use Slim\Factory\AppFactory;
require __DIR__ . '/../vendor/autoload.php';
// Load environment variables
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();
// Load environment variables when a project .env file is present.
// Docker can provide these via env_file/environment as well; in that case
// we should not crash if the file is not mounted into the container.
$dotenvPath = __DIR__ . '/../';
if (is_file($dotenvPath . '.env')) {
$dotenv = Dotenv\Dotenv::createImmutable($dotenvPath);
$dotenv->safeLoad();
}
// Build DI container
$containerBuilder = new ContainerBuilder();