From 1f7383db2b22688f2c5221c83bf47fae229703e7 Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Fri, 7 Aug 2026 19:40:43 +0200 Subject: [PATCH] Replace Composer autoloader with custom PSR-4 autoloader --- bin/docbook-cs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/bin/docbook-cs b/bin/docbook-cs index 66fd862..63c717c 100644 --- a/bin/docbook-cs +++ b/bin/docbook-cs @@ -5,24 +5,10 @@ declare(strict_types=1); use DocbookCS\Application; -// Find the Composer autoloader. -(static function (): void { - $candidates = [ - __DIR__ . '/../vendor/autoload.php', // installed as project root - __DIR__ . '/../../../autoload.php', // installed as a dependency - ]; - - foreach ($candidates as $file) { - if (!is_file($file)) { - continue; - } - - require $file; - return; +spl_autoload_register(static function (string $class): void { + if (str_starts_with($class, 'DocbookCS\\')) { + require __DIR__ . '/../src/' . str_replace('\\', '/', substr($class, 10)) . '.php'; } - - fwrite(STDERR, 'Could not find Composer autoloader. Run "composer install" first.' . PHP_EOL); - exit(2); -})(); +}); exit(Application::withArguments($argv ?? [])->run());