- Move 45 debug/test files from root to organized scripts/ directories - Secure public/ directory by removing debug files (security improvement) - Create structured scripts organization: • scripts/debug/ (20 files) - Framework debugging tools • scripts/test/ (18 files) - Test and validation scripts • scripts/maintenance/ (5 files) - Maintenance utilities • scripts/dev/ (2 files) - Development tools Security improvements: - Removed all debug/test files from public/ directory - Only production files remain: index.php, health.php Root directory cleanup: - Reduced from 47 to 2 PHP files in root - Only essential production files: console.php, worker.php This improves: ✅ Security (no debug code in public/) ✅ Organization (clear separation of concerns) ✅ Maintainability (easy to find and manage scripts) ✅ Professional structure (clean root directory)
80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
use App\Framework\Discovery\UnifiedDiscoveryService;
|
|
use App\Framework\Discovery\ValueObjects\DiscoveryOptions;
|
|
use App\Framework\Cache\Cache;
|
|
use App\Framework\Cache\CacheKey;
|
|
use App\Framework\Cache\CacheItem;
|
|
use App\Framework\Attributes\Route;
|
|
|
|
// Simple null cache for testing
|
|
$cache = new class implements Cache {
|
|
public function get(CacheKey $key): ?CacheItem { return null; }
|
|
public function set(CacheItem ...$items): bool { return true; }
|
|
public function delete(CacheKey ...$keys): bool { return true; }
|
|
public function clear(): bool { return true; }
|
|
public function has(CacheKey $key): bool { return false; }
|
|
};
|
|
|
|
try {
|
|
|
|
// Create discovery service
|
|
$discoveryService = new UnifiedDiscoveryService($cache);
|
|
|
|
// Perform discovery
|
|
$options = new DiscoveryOptions(
|
|
paths: [__DIR__ . '/src'],
|
|
cachingEnabled: false, // Disable caching for test
|
|
attributeTypes: [Route::class]
|
|
);
|
|
|
|
$registry = $discoveryService->discover($options);
|
|
|
|
$routes = $registry->getByAttribute(Route::class);
|
|
|
|
echo "=== DISCOVERED ROUTES ===\n\n";
|
|
echo "Total routes found: " . count($routes) . "\n\n";
|
|
|
|
foreach ($routes as $discovered) {
|
|
$routeAttr = $discovered->attribute->newInstance();
|
|
$className = $discovered->className;
|
|
$methodName = $discovered->methodName ?? '__invoke';
|
|
|
|
echo "Route: {$routeAttr->method->value} {$routeAttr->path}\n";
|
|
echo " Class: {$className}\n";
|
|
echo " Method: {$methodName}\n";
|
|
|
|
// Check for Campaign routes specifically
|
|
if (str_contains($className, 'Campaign')) {
|
|
echo " ⭐ CAMPAIGN ROUTE\n";
|
|
}
|
|
|
|
echo "\n";
|
|
}
|
|
|
|
// Specifically search for PreSaveCampaign
|
|
echo "\n=== SEARCHING FOR PreSaveCampaign ===\n";
|
|
$found = false;
|
|
foreach ($routes as $discovered) {
|
|
if (str_contains($discovered->className, 'PreSaveCampaign')) {
|
|
echo "✅ PreSaveCampaign FOUND!\n";
|
|
echo " Path: {$discovered->attribute->newInstance()->path}\n";
|
|
$found = true;
|
|
}
|
|
}
|
|
|
|
if (!$found) {
|
|
echo "❌ PreSaveCampaign NOT FOUND in discovery!\n";
|
|
}
|
|
|
|
} catch (\Exception $e) {
|
|
echo "❌ Error during discovery: " . $e->getMessage() . "\n";
|
|
echo "File: " . $e->getFile() . ":" . $e->getLine() . "\n";
|
|
echo "\nStack trace:\n";
|
|
echo $e->getTraceAsString() . "\n";
|
|
}
|