refactor: reorganize project structure for better maintainability
- 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)
This commit is contained in:
87
scripts/debug/debug-contexts.php
Normal file
87
scripts/debug/debug-contexts.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Framework\Attributes\Route;
|
||||
use App\Framework\Core\AppBootstrapper;
|
||||
use App\Framework\Discovery\Results\DiscoveryRegistry;
|
||||
use App\Framework\Performance\EnhancedPerformanceCollector;
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
use App\Framework\DateTime\SystemHighResolutionClock;
|
||||
use App\Framework\Performance\MemoryMonitor;
|
||||
use App\Framework\DI\Initializer;
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
require __DIR__ . '/src/Framework/Debug/helpers.php';
|
||||
|
||||
echo "DEBUG: Starting context analysis\n";
|
||||
|
||||
// Create dependencies for enhanced performance collector
|
||||
$basePath = __DIR__;
|
||||
$clock = new SystemClock();
|
||||
$highResClock = new SystemHighResolutionClock();
|
||||
$memoryMonitor = new MemoryMonitor();
|
||||
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: true);
|
||||
|
||||
echo "DEBUG: About to create AppBootstrapper\n";
|
||||
$bootstrapper = new AppBootstrapper($basePath, $collector, $memoryMonitor);
|
||||
|
||||
echo "DEBUG: About to bootstrap web app\n";
|
||||
$app = $bootstrapper->bootstrapWeb();
|
||||
|
||||
echo "DEBUG: Web app bootstrapped successfully\n";
|
||||
|
||||
// Get container from the app
|
||||
$reflection = new ReflectionObject($app);
|
||||
$containerProperty = $reflection->getProperty('container');
|
||||
$containerProperty->setAccessible(true);
|
||||
$container = $containerProperty->getValue($app);
|
||||
|
||||
echo "DEBUG: Got container from app\n";
|
||||
|
||||
// Check if DiscoveryRegistry is available
|
||||
if ($container->has(DiscoveryRegistry::class)) {
|
||||
echo "DEBUG: DiscoveryRegistry is available in container\n";
|
||||
$registry = $container->get(DiscoveryRegistry::class);
|
||||
|
||||
$initializerCount = $registry->attributes->getCount(Initializer::class);
|
||||
echo "DEBUG: Found $initializerCount initializer attributes in registry\n";
|
||||
|
||||
if ($initializerCount > 0) {
|
||||
$initializers = $registry->attributes->get(Initializer::class);
|
||||
echo "DEBUG: Looking for router-related initializers\n";
|
||||
|
||||
foreach ($initializers as $initializer) {
|
||||
$className = $initializer->className->getFullyQualified();
|
||||
|
||||
if (str_contains($className, 'Router') || str_contains($className, 'Route')) {
|
||||
echo " ROUTER INITIALIZER: $className\n";
|
||||
|
||||
// Get the attribute instance to see the contexts
|
||||
$attributeInstance = $initializer->createAttributeInstance();
|
||||
if ($attributeInstance instanceof \App\Framework\DI\Initializer) {
|
||||
$contexts = $attributeInstance->contexts;
|
||||
if (empty($contexts)) {
|
||||
echo " CONTEXTS: ALL (no restrictions)\n";
|
||||
} else {
|
||||
$contextNames = array_map(function($ctx) {
|
||||
return $ctx instanceof \App\Framework\Context\ContextType ? $ctx->name : (string)$ctx;
|
||||
}, $contexts);
|
||||
echo " CONTEXTS: " . implode(', ', $contextNames) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Check additionalData for debugging
|
||||
if (isset($initializer->additionalData['contexts'])) {
|
||||
echo " STORED CONTEXTS: " . print_r($initializer->additionalData['contexts'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "DEBUG: No initializers found in registry\n";
|
||||
}
|
||||
} else {
|
||||
echo "DEBUG: DiscoveryRegistry is NOT available in container\n";
|
||||
}
|
||||
|
||||
echo "DEBUG: Context analysis complete\n";
|
||||
Reference in New Issue
Block a user