addRuntimeInstances() $basePath = '/home/michael/dev/michaelschiemer'; // Create dependencies for performance collector (like console.php) $clock = new SystemClock(); $highResClock = new SystemHighResolutionClock(); $memoryMonitor = new MemoryMonitor(); $collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: false); echo "1. Setting up runtime instances:\n"; $container->instance(Logger::class, new DefaultLogger()); $container->instance(PerformanceCollectorInterface::class, $collector); // Get the cache instance to debug it $cache = new CacheInitializer($collector, $container)(); $container->instance(Cache::class, $cache); $pathProvider = new PathProvider($basePath); $container->instance(PathProvider::class, $pathProvider); $container->instance(ResponseEmitter::class, new ResponseEmitter()); $container->instance(Clock::class, $clock); echo " - Runtime instances registered\n"; echo " - Cache type: " . get_class($cache) . "\n"; echo " - Base path: " . $basePath . "\n"; echo " - Source path: " . $pathProvider->getSourcePath() . "\n"; // Clear any existing cache $cache->clear(); echo " - Cache cleared\n"; // Step 2: Now do discovery bootstrap exactly like ContainerBootstrapper->autowire() echo "2. Running discovery bootstrap (like ContainerBootstrapper):\n"; try { $discoveryBootstrapper = new DiscoveryServiceBootstrapper($container, $clock); echo " - DiscoveryServiceBootstrapper created\n"; // Use the exact same call as ContainerBootstrapper->autowire() $results = $discoveryBootstrapper->bootstrap(); echo " - Discovery bootstrap completed\n"; echo " - Registry empty: " . ($results->isEmpty() ? 'YES' : 'NO') . "\n"; echo " - Total attribute types: " . count($results->attributes->getAllTypes()) . "\n"; $consoleCommands = $results->attributes->get(ConsoleCommand::class); echo " - ConsoleCommand attributes found: " . count($consoleCommands) . "\n"; if (count($consoleCommands) > 0) { echo " - ✅ SUCCESS! Discovery is working with full setup\n"; echo " - Sample commands:\n"; $sampleCount = 0; foreach ($consoleCommands as $discovered) { if ($sampleCount >= 5) { break; } $command = $discovered->createAttributeInstance(); echo " * " . $command->name . " - " . $command->description . "\n"; $sampleCount++; } } else { echo " - ❌ Still no commands found. All discovered types:\n"; foreach ($results->attributes->getAllTypes() as $type) { $count = $results->attributes->getCount($type); echo " * $type: $count instances\n"; } } } catch (\Throwable $e) { echo " - ❌ Error: " . $e->getMessage() . "\n"; echo " - File: " . $e->getFile() . ":" . $e->getLine() . "\n"; echo " - Stack trace:\n" . $e->getTraceAsString() . "\n"; } echo "\n=== End Test ===\n";