fadrian06 12 months ago
parent db02086d21
commit afba9c16a0

@ -28,8 +28,7 @@
}, },
"autoload": { "autoload": {
"files": [ "files": [
"flight/autoload.php", "flight/autoload.php"
"flight/Flight.php"
] ]
}, },
"autoload-dev": { "autoload-dev": {

@ -10,6 +10,8 @@ use flight\net\Router;
use flight\template\View; use flight\template\View;
use flight\net\Route; use flight\net\Route;
require_once __DIR__ . '/autoload.php';
/** /**
* The Flight class is a static representation of the framework. * The Flight class is a static representation of the framework.
* *

@ -4,6 +4,7 @@ declare(strict_types=1);
use flight\core\Loader; use flight\core\Loader;
require_once __DIR__ . '/Flight.php';
require_once __DIR__ . '/core/Loader.php'; require_once __DIR__ . '/core/Loader.php';
Loader::autoload(true, [dirname(__DIR__)]); Loader::autoload(true, [dirname(__DIR__)]);

@ -190,12 +190,13 @@ class Loader
*/ */
public static function loadClass(string $class): void public static function loadClass(string $class): void
{ {
$class_file = str_replace(['\\', '_'], '/', $class) . '.php'; $classFile = str_replace(['\\', '_'], '/', $class) . '.php';
foreach (self::$dirs as $dir) { foreach (self::$dirs as $dir) {
$file = $dir . '/' . $class_file; $filePath = "$dir/$classFile";
if (file_exists($file)) {
require $file; if (file_exists($filePath)) {
require_once $filePath;
return; return;
} }

@ -1,6 +1,7 @@
<?php <?php
require 'flight/Flight.php'; // require 'flight/Flight.php';
require 'flight/autoload.php';
Flight::route('/', function () { Flight::route('/', function () {
echo 'hello world!'; echo 'hello world!';

@ -36,6 +36,8 @@
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" /> <exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" />
<exclude name="Generic.Commenting.DocComment.MissingShort" /> <exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="Generic.Commenting.DocComment.SpacingBeforeTags" /> <exclude name="Generic.Commenting.DocComment.SpacingBeforeTags" />
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen" />
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose" />
</rule> </rule>
<file>flight/</file> <file>flight/</file>
<file>tests/</file> <file>tests/</file>

Loading…
Cancel
Save