singleton(\App\Framework\Cache\Cache::class, $cache); $container->singleton(\App\Framework\DateTime\Clock::class, $clock); $container->singleton(PathProvider::class, $pathProvider); $reflectionProvider = new CachedReflectionProvider(); $executionContext = ExecutionContext::detect(); $container->singleton(\App\Framework\Reflection\ReflectionProvider::class, $reflectionProvider); $container->singleton(ExecutionContext::class, $executionContext); $container->singleton(InitializerProcessor::class, fn ($c) => new InitializerProcessor( $c, $c->get(\App\Framework\Reflection\ReflectionProvider::class), $c->get(ExecutionContext::class) )); // App config for testing $appConfig = new AppConfig( environment: 'testing', debug: true, timezone: Timezone::UTC, locale: 'en' ); $container->singleton(AppConfig::class, $appConfig); // Clear cache $cache->clear(); echo "1. Environment Setup:\n"; echo " - Context: " . $executionContext->getType()->value . "\n"; echo " - Source Path: " . $pathProvider->getSourcePath() . "\n"; echo " - Cache cleared: ✓\n\n"; // Test basic reflection first echo "2. Basic Reflection Test:\n"; $reflection = new ReflectionClass(\App\Framework\Console\DemoCommand::class); $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC); $foundCommands = 0; foreach ($methods as $method) { $attributes = $method->getAttributes(ConsoleCommand::class); $foundCommands += count($attributes); foreach ($attributes as $attribute) { $command = $attribute->newInstance(); echo " - Found: " . $command->name . "\n"; } } echo " - Total demo commands found via reflection: $foundCommands\n\n"; // Test discovery service echo "3. Discovery Service Test:\n"; // Let's also check if the UnifiedDiscoveryService exists in container if ($container->has(\App\Framework\Discovery\UnifiedDiscoveryService::class)) { echo " - UnifiedDiscoveryService already in container\n"; } else { echo " - UnifiedDiscoveryService not in container - will be created\n"; } $bootstrapper = new DiscoveryServiceBootstrapper($container, $clock); try { echo " - Starting bootstrap process...\n"; // Let's use performBootstrap directly to avoid cached results $registry = $bootstrapper->performBootstrap($pathProvider, $cache, null); echo " - Bootstrap completed successfully\n"; $consoleCommands = $registry->attributes->get(ConsoleCommand::class); $discoveredCount = count($consoleCommands); echo " - Total commands found via discovery: $discoveredCount\n"; if ($discoveredCount === 0) { echo " - ❌ No commands discovered - investigating...\n"; // Check registry contents echo " - Registry empty: " . ($registry->isEmpty() ? 'YES' : 'NO') . "\n"; // Check what types are available $allTypes = $registry->attributes->getAllTypes(); echo " - Total attribute types in registry: " . count($allTypes) . "\n"; foreach ($allTypes as $type) { $count = $registry->attributes->getCount($type); echo " - Found $type: $count instances\n"; } // Let's also manually check if we have the specific type $hasConsoleCommand = $registry->attributes->has(ConsoleCommand::class); echo " - Has ConsoleCommand type: " . ($hasConsoleCommand ? 'YES' : 'NO') . "\n"; } else { echo " - ✓ Discovery working!\n"; echo " - Sample commands:\n"; $count = 0; foreach ($consoleCommands as $discovered) { if ($count >= 5) { echo " - ... and " . ($discoveredCount - 5) . " more\n"; break; } $command = $discovered->createAttributeInstance(); echo " - " . $command->name . "\n"; $count++; } } } catch (\Throwable $e) { echo " - ❌ Discovery failed with exception:\n"; echo " - Error: " . $e->getMessage() . "\n"; echo " - File: " . $e->getFile() . ":" . $e->getLine() . "\n"; } echo "\n=== End Diagnosis ===\n";