diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1013126 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +DB_HOST= +DB_PORT= +DB_DATABASE= +DB_USERNAME= +DB_PASSWORD= diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/app/src/Config.php b/app/src/Config.php index 3d553ff..fce9d22 100644 --- a/app/src/Config.php +++ b/app/src/Config.php @@ -14,12 +14,13 @@ private function __construct( ) {} public static function create(): self { + $env = parse_ini_file('../../.env'); return new self( - '127.0.0.1', - 3306, - 'todo_demo', - 'root', - '' + $env['DB_HOST'] ?? 'localhost', + isset($env['DB_PORT']) ? (int)$env['DB_PORT'] : 3306, + $env['DB_NAME'] ?? 'app_db', + $env['DB_USER'] ?? 'app_user', + $env['DB_PASS'] ?? 'secret_password' ); }