fix: replace custom autoloader with composer PSR-4 autoloader
All checks were successful
Deploy Feature Branch to Test / deploy (push) Successful in 29s
Lint / PHP Syntax Check (push) Successful in 37s
Lint / CSS Lint (stylelint) (push) Successful in 1m17s
Lint / HTML Lint (htmlhint) (push) Successful in 1m15s
Lint / PHP Syntax Check (pull_request) Successful in 32s
Lint / CSS Lint (stylelint) (pull_request) Successful in 1m12s
Lint / HTML Lint (htmlhint) (pull_request) Successful in 1m8s

The custom autoloader used lowercase directory names which broke
after renaming app/core/ → app/Core/ and app/controllers/ → app/Controllers/
for PSR-4 compliance.
This commit is contained in:
greggy
2026-05-22 19:19:28 +00:00
parent 57b97b5069
commit 3a30abc05e

24
public/index.php Normal file → Executable file
View File

@@ -7,28 +7,8 @@ declare(strict_types=1);
* All requests are routed through this file. * All requests are routed through this file.
*/ */
// Autoloader (PSR-4 style, simple) // Autoloader (composer PSR-4)
spl_autoload_register(function (string $class): void { require_once __DIR__ . '/../vendor/autoload.php';
$prefix = 'App\\';
$baseDir = __DIR__ . '/../app/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relativeClass = substr($class, $len);
// Lowercase directory names, keep class name case
$parts = explode('\\', $relativeClass);
$className = array_pop($parts);
$parts = array_map('strtolower', $parts);
$parts[] = $className;
$file = $baseDir . implode('/', $parts) . '.php';
if (file_exists($file)) {
require $file;
}
});
use App\Core\Router; use App\Core\Router;