diff --git a/composer.json b/composer.json index e6fd63a3..d36788db 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,7 @@ }, "autoload": { "files": [ - "flight/autoload.php", - "flight/Flight.php" + "flight/autoload.php" ] }, "autoload-dev": { diff --git a/flight/Flight.php b/flight/Flight.php index 837d0bcf..c53b9799 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -10,6 +10,8 @@ use flight\template\View; use flight\net\Route; +require_once __DIR__ . '/autoload.php'; + /** * The Flight class is a static representation of the framework. * diff --git a/flight/autoload.php b/flight/autoload.php index 3a7ea5a0..0a31c864 100644 --- a/flight/autoload.php +++ b/flight/autoload.php @@ -4,6 +4,7 @@ use flight\core\Loader; +require_once __DIR__ . '/Flight.php'; require_once __DIR__ . '/core/Loader.php'; Loader::autoload(true, [dirname(__DIR__)]); diff --git a/flight/core/Loader.php b/flight/core/Loader.php index 3bd36966..9792949a 100644 --- a/flight/core/Loader.php +++ b/flight/core/Loader.php @@ -190,12 +190,13 @@ public static function autoload(bool $enabled = true, $dirs = []): void */ public static function loadClass(string $class): void { - $class_file = str_replace(['\\', '_'], '/', $class) . '.php'; + $classFile = str_replace(['\\', '_'], '/', $class) . '.php'; foreach (self::$dirs as $dir) { - $file = $dir . '/' . $class_file; - if (file_exists($file)) { - require $file; + $filePath = "$dir/$classFile"; + + if (file_exists($filePath)) { + require_once $filePath; return; } diff --git a/index.php b/index.php index 65cdd7e8..5a21ed6d 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,7 @@ + + flight/ tests/