#!/usr/bin/env php createForDevelopment(); echo "Running discovery..." . PHP_EOL; $startTime = microtime(true); $registry = $discovery->discover(); $duration = round((microtime(true) - $startTime) * 1000, 2); echo "Discovery completed in {$duration}ms" . PHP_EOL; echo "Total items discovered: " . count($registry) . PHP_EOL; echo "Files processed: " . $registry->getFileCount() . PHP_EOL; echo PHP_EOL; // Get all routes from AttributeRegistry $routes = $registry->attributes->get(App\Framework\Attributes\Route::class); echo "Total routes found: " . count($routes) . PHP_EOL; echo PHP_EOL; // Filter Campaign routes echo "=== Looking for Campaign Routes ===" . PHP_EOL; $campaignRoutes = []; foreach ($routes as $attr) { $className = $attr->className->toString(); if (str_contains($className, 'Campaign')) { $campaignRoutes[] = $attr; } } echo "Campaign routes found: " . count($campaignRoutes) . PHP_EOL; echo PHP_EOL; if (count($campaignRoutes) > 0) { foreach ($campaignRoutes as $attr) { echo "✅ Route found:" . PHP_EOL; echo " Class: " . $attr->className->toString() . PHP_EOL; echo " Method: " . $attr->methodName->toString() . PHP_EOL; echo " Path: " . $attr->instance->path . PHP_EOL; echo " HTTP Method: " . $attr->instance->method->value . PHP_EOL; echo PHP_EOL; } } else { echo "❌ NO CAMPAIGN ROUTES FOUND!" . PHP_EOL; echo PHP_EOL; // Debug: Show what was actually discovered echo "=== All Discovered Routes (first 10) ===" . PHP_EOL; $count = 0; foreach ($routes as $attr) { echo " " . $attr->className->toString() . "::" . $attr->methodName->toString() . PHP_EOL; echo " Path: " . $attr->instance->path . PHP_EOL; $count++; if ($count >= 10) { echo " ... and " . (count($routes) - 10) . " more" . PHP_EOL; break; } } } // Specific check for PreSaveCampaign echo PHP_EOL . "=== Specific PreSaveCampaign Check ===" . PHP_EOL; $preSaveFound = false; foreach ($routes as $attr) { if ($attr->className->toString() === 'App\\Application\\Campaign\\PreSaveCampaign') { $preSaveFound = true; echo "✅ PreSaveCampaign found!" . PHP_EOL; echo " Path: " . $attr->instance->path . PHP_EOL; echo " Expected: /campaign/{slug}/presave/{platform}" . PHP_EOL; break; } } if (! $preSaveFound) { echo "❌ PreSaveCampaign NOT found in discovery!" . PHP_EOL; // Check if the file exists $preSaveFile = $basePath . '/src/Application/Campaign/PreSaveCampaign.php'; echo PHP_EOL . "File exists: " . (file_exists($preSaveFile) ? 'yes' : 'no') . PHP_EOL; echo "File readable: " . (is_readable($preSaveFile) ? 'yes' : 'no') . PHP_EOL; // Try to load the class directly if (class_exists('App\\Application\\Campaign\\PreSaveCampaign')) { echo "Class can be loaded: yes" . PHP_EOL; $reflection = new ReflectionClass('App\\Application\\Campaign\\PreSaveCampaign'); $method = $reflection->getMethod('__invoke'); $routeAttrs = $method->getAttributes(Route::class); echo "Route attributes on __invoke method: " . count($routeAttrs) . PHP_EOL; if (count($routeAttrs) > 0) { echo "❌ Route attribute EXISTS but was NOT discovered!" . PHP_EOL; echo "This indicates a problem with the discovery system!" . PHP_EOL; } } } echo PHP_EOL . "=== Test Complete ===" . PHP_EOL;