From dd4b707d12f241039e29a77dbe0129a545a4a727 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 9 Oct 2023 13:15:37 +0000 Subject: [PATCH] Do autoloading without composer --- kilo | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/kilo b/kilo index b46843b..b780839 100755 --- a/kilo +++ b/kilo @@ -3,7 +3,30 @@ 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 set_error_handler(static function (