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:
2025-10-05 10:59:15 +02:00
parent 03e5188644
commit 887847dde6
77 changed files with 3902 additions and 787 deletions

View File

@@ -0,0 +1,94 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
require_once __DIR__ . '/vendor/autoload.php';
use App\Framework\Core\AppBootstrapper;
use App\Framework\Performance\EnhancedPerformanceCollector;
use App\Framework\DateTime\SystemClock;
use App\Framework\DateTime\SystemHighResolutionClock;
use App\Framework\Performance\MemoryMonitor;
use App\Framework\Discovery\Results\DiscoveryRegistry;
use App\Framework\Console\ConsoleApplication;
try {
echo "1. Creating performance collector..." . PHP_EOL;
$clock = new SystemClock();
$highResClock = new SystemHighResolutionClock();
$memoryMonitor = new MemoryMonitor();
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: false);
echo "2. Creating bootstrapper..." . PHP_EOL;
$bootstrapper = new AppBootstrapper(__DIR__, $collector, $memoryMonitor);
echo "3. Bootstrapping console..." . PHP_EOL;
$consoleApp = $bootstrapper->bootstrapConsole();
echo "4. Getting container from console app..." . PHP_EOL;
$reflection = new ReflectionClass($consoleApp);
$containerProperty = $reflection->getProperty('container');
$containerProperty->setAccessible(true);
$container = $containerProperty->getValue($consoleApp);
echo "5. Checking if DiscoveryRegistry is in container..." . PHP_EOL;
$hasDiscoveryRegistry = $container->has(DiscoveryRegistry::class);
echo " DiscoveryRegistry available: " . ($hasDiscoveryRegistry ? 'YES' : 'NO') . PHP_EOL;
if ($hasDiscoveryRegistry) {
echo "6. Getting DiscoveryRegistry..." . PHP_EOL;
$discoveryRegistry = $container->get(DiscoveryRegistry::class);
echo " DiscoveryRegistry type: " . get_class($discoveryRegistry) . PHP_EOL;
echo " Total attributes: " . $discoveryRegistry->attributes->count() . PHP_EOL;
// Show all discovered attribute types
$allTypes = $discoveryRegistry->attributes->getAllTypes();
echo " All discovered attribute types: " . implode(', ', $allTypes) . PHP_EOL;
$commands = $discoveryRegistry->attributes->get(\App\Framework\Console\ConsoleCommand::class);
echo " ConsoleCommand attributes: " . count($commands) . PHP_EOL;
if (count($commands) > 0) {
foreach (array_slice($commands, 0, 5) as $discovered) {
$methodName = $discovered->methodName ? $discovered->methodName->toString() : '__invoke';
echo " - " . $discovered->className->getFullyQualified() . "::" . $methodName . PHP_EOL;
$command = $discovered->createAttributeInstance();
echo " Command: " . $command->name . PHP_EOL;
}
} else {
echo " No ConsoleCommand attributes found!" . PHP_EOL;
echo " This suggests ConsoleCommandMapper is not included or working properly" . PHP_EOL;
}
} else {
echo "6. DiscoveryRegistry NOT found in container!" . PHP_EOL;
}
echo "7. Checking ConsoleApplication's command registry..." . PHP_EOL;
$registryProperty = $reflection->getProperty('commandRegistry');
$registryProperty->setAccessible(true);
$commandRegistry = $registryProperty->getValue($consoleApp);
if ($commandRegistry === null) {
echo " CommandRegistry is NULL!" . PHP_EOL;
echo " This means initializeCommandRegistry was never called or failed" . PHP_EOL;
} else {
echo " CommandRegistry type: " . get_class($commandRegistry) . PHP_EOL;
// Try to get the command list from the registry
$commandRegistryReflection = new ReflectionClass($commandRegistry);
$commandListProperty = $commandRegistryReflection->getProperty('commandList');
$commandListProperty->setAccessible(true);
$commandList = $commandListProperty->getValue($commandRegistry);
if ($commandList === null) {
echo " CommandList is NULL in CommandRegistry!" . PHP_EOL;
} else {
echo " CommandList type: " . get_class($commandList) . PHP_EOL;
echo " Command count: " . $commandList->count() . PHP_EOL;
}
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . PHP_EOL;
echo "Stack trace: " . $e->getTraceAsString() . PHP_EOL;
}