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:
69
scripts/test/test_request_container.php
Normal file
69
scripts/test/test_request_container.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use App\Framework\Performance\EnhancedPerformanceCollector;
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
use App\Framework\DateTime\SystemHighResolutionClock;
|
||||
use App\Framework\Core\AppBootstrapper;
|
||||
use App\Framework\Performance\MemoryMonitor;
|
||||
|
||||
echo "=== Request Container Test ===\n";
|
||||
|
||||
try {
|
||||
$basePath = __DIR__;
|
||||
$clock = new SystemClock();
|
||||
$highResClock = new SystemHighResolutionClock();
|
||||
$memoryMonitor = new MemoryMonitor();
|
||||
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: true);
|
||||
$bootstrapper = new AppBootstrapper($basePath, $collector, $memoryMonitor);
|
||||
|
||||
echo "1. Creating worker container...\n";
|
||||
$container = $bootstrapper->bootstrapWorker();
|
||||
|
||||
echo "2. Container created successfully\n";
|
||||
echo "3. Testing Request resolution...\n";
|
||||
|
||||
// Try to resolve Request interface
|
||||
$request = $container->get('App\\Framework\\Http\\Request');
|
||||
echo "4. ✅ SUCCESS: Request resolved as " . get_class($request) . "\n";
|
||||
echo "5. Is HttpRequest instance: " . ($request instanceof \App\Framework\Http\HttpRequest ? 'YES' : 'NO') . "\n";
|
||||
|
||||
// Check discovery registry
|
||||
echo "\n=== Discovery Registry Check ===\n";
|
||||
$registry = $container->get('App\\Framework\\Discovery\\Results\\DiscoveryRegistry');
|
||||
$initializers = $registry->getInitializersByClass();
|
||||
echo "Total initializers: " . count($initializers) . "\n";
|
||||
|
||||
$requestFactoryFound = false;
|
||||
foreach ($initializers as $class => $methods) {
|
||||
if (str_contains($class, 'RequestFactory')) {
|
||||
echo "Found RequestFactory: $class\n";
|
||||
foreach ($methods as $method) {
|
||||
echo " Method: $method\n";
|
||||
}
|
||||
$requestFactoryFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$requestFactoryFound) {
|
||||
echo "❌ RequestFactory not found in discovery registry!\n";
|
||||
}
|
||||
|
||||
// Try creating request directly
|
||||
echo "\n=== Direct Request Creation Test ===\n";
|
||||
$requestFactory = $container->get('App\\Framework\\Http\\RequestFactory');
|
||||
echo "RequestFactory resolved: " . get_class($requestFactory) . "\n";
|
||||
|
||||
$directRequest = $requestFactory->createFromGlobals();
|
||||
echo "Direct request created: " . get_class($directRequest) . "\n";
|
||||
echo "Is Request interface: " . ($directRequest instanceof \App\Framework\Http\Request ? 'YES' : 'NO') . "\n";
|
||||
|
||||
} catch (Throwable $e) {
|
||||
echo "ERROR: " . $e->getMessage() . "\n";
|
||||
echo "FILE: " . $e->getFile() . ":" . $e->getLine() . "\n";
|
||||
if (str_contains($e->getMessage(), 'Cannot instantiate')) {
|
||||
echo "\n=== ANALYSIS ===\n";
|
||||
echo "This suggests the Discovery system did not register the RequestFactory initializer\n";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user