Do autoloading without composer
All checks were successful
timw4mail/php-kilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2023-10-09 13:15:37 +00:00
parent 26ea12883a
commit dd4b707d12

25
kilo
View File

@ -3,7 +3,30 @@
namespace Aviat\Kilo; namespace Aviat\Kilo;
require_once __DIR__ . '/vendor/autoload.php'; require_once __DIR__ . '/src/constants.php';
require_once __DIR__ . '/src/config.php';
require_once __DIR__ . '/src/functions.php';
// Remove the composer install requirement by
// manually handling autoloading
spl_autoload_register(function (string $class) {
$nsParts = explode('\\', $class);
array_shift($nsParts);
array_shift($nsParts);
array_unshift($nsParts, __DIR__, 'src');
$file = implode(DIRECTORY_SEPARATOR, $nsParts) . '.php';
if (file_exists($file))
{
require_once($file);
return true;
}
return false;
});
// Log notices/errors/warnings to file // Log notices/errors/warnings to file
set_error_handler(static function ( set_error_handler(static function (