Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fadrian06 committed Feb 4, 2024
1 parent db02086 commit afba9c1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
},
"autoload": {
"files": [
"flight/autoload.php",
"flight/Flight.php"
"flight/autoload.php"
]
},
"autoload-dev": {
Expand Down
2 changes: 2 additions & 0 deletions flight/Flight.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
1 change: 1 addition & 0 deletions flight/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use flight\core\Loader;

require_once __DIR__ . '/Flight.php';
require_once __DIR__ . '/core/Loader.php';

Loader::autoload(true, [dirname(__DIR__)]);
9 changes: 5 additions & 4 deletions flight/core/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

require 'flight/Flight.php';
// require 'flight/Flight.php';
require 'flight/autoload.php';

Flight::route('/', function () {
echo 'hello world!';
Expand Down
2 changes: 2 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="Generic.Commenting.DocComment.SpacingBeforeTags" />
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceAfterOpen" />
<exclude name="Generic.WhiteSpace.ArbitraryParenthesesSpacing.SpaceBeforeClose" />
</rule>
<file>flight/</file>
<file>tests/</file>
Expand Down

0 comments on commit afba9c1

Please sign in to comment.