From e7bdf7cbc734b986b1bd0ed9937c21e4b43555ed Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 6 Jun 2026 12:34:33 -0500 Subject: [PATCH] fix: load Composer autoloader in CliFramework constructor (#248) CLI tools failed with "Class MokoEnterprise\SourceResolver not found" because the Composer autoloader was never loaded. The require_once for CliFramework.php loaded the framework but not the PSR-4 autoloader that maps MokoEnterprise\ to lib/Enterprise/. Adding require_once for vendor/autoload.php in the constructor ensures all Enterprise classes (SourceResolver, etc.) are available to every CLI tool that extends CliFramework. Closes #248 Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/Enterprise/CliFramework.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Enterprise/CliFramework.php b/lib/Enterprise/CliFramework.php index 91a9a0b..ab4534e 100644 --- a/lib/Enterprise/CliFramework.php +++ b/lib/Enterprise/CliFramework.php @@ -171,6 +171,13 @@ abstract class CliFramework */ public function __construct(string $name = '', string $version = '04.00.15') { + // Load Composer autoloader for Enterprise classes (SourceResolver, etc.) + $autoloader = __DIR__ . '/../../vendor/autoload.php'; + + if (file_exists($autoloader)) { + require_once $autoloader; + } + $this->scriptName = $name ?: basename($_SERVER['argv'][0] ?? 'script', '.php'); $this->scriptVersion = $version; $this->startTime = microtime(true);