diff --git a/composer.json b/composer.json index e6fd63a..d36788d 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 837d0bc..c53b979 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -10,6 +10,8 @@ use flight\net\Router; 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 3a7ea5a..0a31c86 100644 --- a/flight/autoload.php +++ b/flight/autoload.php @@ -4,6 +4,7 @@ declare(strict_types=1); 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 3bd3696..9792949 100644 --- a/flight/core/Loader.php +++ b/flight/core/Loader.php @@ -190,12 +190,13 @@ class Loader */ 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 65cdd7e..5a21ed6 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,7 @@ + + flight/ tests/