From d80970c452e921277297195688a327693dda8f55 Mon Sep 17 00:00:00 2001 From: Ramon Caballero Date: Thu, 9 Apr 2026 16:39:30 +0100 Subject: [PATCH] Introduce project path constants for cleaner initialization --- public/index.php | 7 +++++-- tests/bootstrap.php | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/public/index.php b/public/index.php index 4e2e452..a511478 100644 --- a/public/index.php +++ b/public/index.php @@ -2,11 +2,14 @@ declare(strict_types=1); -require_once __DIR__ . '/../vendor/autoload.php'; +define('PROJECT_ROOT', dirname(__DIR__)); +define('CONFIG_DIRECTORY', PROJECT_ROOT . '/config/'); + +require_once PROJECT_ROOT . '/vendor/autoload.php'; use Dotenv\Dotenv; -$dotenv = Dotenv::createImmutable(__DIR__ . '/../config', 'PHPStarter.env'); +$dotenv = Dotenv::createImmutable(CONFIG_DIRECTORY, 'PHPStarter.env'); $dotenv->load(); use PHPStarter\DB; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 06fdcb4..d0d74a2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,4 +2,6 @@ declare(strict_types=1); -require __DIR__ . '/../vendor/autoload.php'; +define('PROJECT_ROOT', dirname(__DIR__)); + +require_once PROJECT_ROOT . '/vendor/autoload.php';