bootstrapConsole(); echo " - Console application created successfully\n"; // Get container and check discovery registry $container = $consoleApp->getContainer(); if ($container->has(DiscoveryRegistry::class)) { echo " - DiscoveryRegistry found in container\n"; $registry = $container->get(DiscoveryRegistry::class); echo " - Registry empty: " . ($registry->isEmpty() ? 'YES' : 'NO') . "\n"; echo " - Total attribute types: " . count($registry->attributes->getAllTypes()) . "\n"; $consoleCommands = $registry->attributes->get(ConsoleCommand::class); echo " - ConsoleCommand attributes found: " . count($consoleCommands) . "\n"; if (count($consoleCommands) > 0) { echo " - ✅ SUCCESS! Discovery working exactly like console.php\n"; echo " - Sample commands:\n"; $sampleCount = 0; foreach ($consoleCommands as $discovered) { if ($sampleCount >= 10) { break; } $command = $discovered->createAttributeInstance(); echo " * " . $command->name . " - " . $command->description . "\n"; $sampleCount++; } echo " ... and " . (count($consoleCommands) - 10) . " more\n"; } else { echo " - ❌ Still no commands found\n"; echo " - All discovered attribute types:\n"; foreach ($registry->attributes->getAllTypes() as $type) { $count = $registry->attributes->getCount($type); echo " * $type: $count instances\n"; } } } else { echo " - ❌ DiscoveryRegistry not found in container\n"; echo " - Available container bindings:\n"; // Can't easily list container bindings with DefaultContainer } } 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";