From 777b531ce77e4f847bc0fe2d1e91bd442913f5de Mon Sep 17 00:00:00 2001 From: Guillermo Pages Date: Wed, 14 Jan 2026 14:15:28 +0100 Subject: [PATCH] refactor: replace hardcoded credentials with env vars - Use getenv() with RuntimeException for missing required vars - Add .env.example template - Add .env to .gitignore - Fix missing return statement in config array --- .env.example | 4 ++++ .gitignore | 1 + config/configuration.local.php | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 .env.example create mode 100644 config/configuration.local.php diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..032c134 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +# Database configuration +DB_DSN=odbc:Driver=FreeTDS; Server=localhost; Port=1218; Database=mydb +DB_USER=myuser +DB_PASSWORD=changeme diff --git a/.gitignore b/.gitignore index 4de37ac..52256f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor *.lock +.env diff --git a/config/configuration.local.php b/config/configuration.local.php new file mode 100644 index 0000000..6dbf1a6 --- /dev/null +++ b/config/configuration.local.php @@ -0,0 +1,24 @@ + + array( + 'driver_class' => '\PDO', + 'dsn' => $getEnvOrThrow('DB_DSN'), + 'driver_params' => array( + 'username' => $getEnvOrThrow('DB_USER'), + 'password' => $getEnvOrThrow('DB_PASSWORD'), + ), + ) +);