itmo-php-course/engine/core/Autoloader.php
2025-01-18 13:32:57 +03:00

19 lines
468 B
PHP

<?php
class Autoloader
{
static function init()
{
spl_autoload_register(function ($class_name) {
// print('auto: ' . $class_name);
$dir = ['/../app/controller/'];
// print($dir);
foreach ($dir as $path) {
$path = __DIR__ . $path . $class_name . '.php';
if (file_exists($path)) {
include_once($path);
}
}
});
}
}