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:
73
scripts/maintenance/bootstrap-discovery.php
Normal file
73
scripts/maintenance/bootstrap-discovery.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Bootstrap Discovery System
|
||||
*
|
||||
* This script runs the discovery scanners and stores results
|
||||
* Run this ONCE to initialize the new discovery system
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use App\Framework\BuildTime\Discovery\Scanners\AttributeScanner;
|
||||
use App\Framework\BuildTime\Discovery\Scanners\InterfaceScanner;
|
||||
use App\Framework\BuildTime\Discovery\Scanners\TemplateScanner;
|
||||
use App\Framework\Core\PathProvider;
|
||||
use App\Framework\Discovery\Storage\DiscoveryStorageService;
|
||||
use App\Framework\Filesystem\FileScanner;
|
||||
use App\Framework\Filesystem\FileSystemService;
|
||||
use App\Framework\Logging\NullLogger;
|
||||
use App\Framework\Reflection\CachedReflectionProvider;
|
||||
|
||||
echo "🚀 Bootstrapping Discovery System...\n\n";
|
||||
$totalStart = microtime(true);
|
||||
|
||||
// Create dependencies
|
||||
$basePath = __DIR__;
|
||||
$pathProvider = new PathProvider($basePath);
|
||||
$storage = new DiscoveryStorageService($pathProvider);
|
||||
$fileSystemService = new FileSystemService();
|
||||
$logger = null;
|
||||
$fileScanner = new FileScanner($logger, null, $fileSystemService);
|
||||
$reflectionProvider = new CachedReflectionProvider();
|
||||
|
||||
// 1. Discover Attributes
|
||||
echo "📦 Discovering attributes...\n";
|
||||
$attrStart = microtime(true);
|
||||
$attributeScanner = new AttributeScanner($fileScanner, $reflectionProvider);
|
||||
$paths = [$pathProvider->getSourcePath()];
|
||||
$attributeRegistry = $attributeScanner->scan($paths);
|
||||
$storage->storeAttributes($attributeRegistry);
|
||||
$attrDuration = round((microtime(true) - $attrStart) * 1000, 2);
|
||||
echo " ✅ {$attributeRegistry->count()} attributes in {$attrDuration}ms\n\n";
|
||||
|
||||
// 2. Discover Templates
|
||||
echo "📄 Discovering templates...\n";
|
||||
$tplStart = microtime(true);
|
||||
$templateScanner = new TemplateScanner($fileScanner);
|
||||
$templatePaths = [
|
||||
$pathProvider->getSourcePath(),
|
||||
$pathProvider->getBasePath() . '/resources'
|
||||
];
|
||||
$templateRegistry = $templateScanner->scan($templatePaths);
|
||||
$storage->storeTemplates($templateRegistry);
|
||||
$tplDuration = round((microtime(true) - $tplStart) * 1000, 2);
|
||||
echo " ✅ " . count($templateRegistry->getAll()) . " templates in {$tplDuration}ms\n\n";
|
||||
|
||||
// 3. Discover Interfaces
|
||||
echo "🔌 Discovering interface implementations...\n";
|
||||
$intStart = microtime(true);
|
||||
$interfaceScanner = new InterfaceScanner($fileScanner, $reflectionProvider, []);
|
||||
$interfaceRegistry = $interfaceScanner->scan($paths);
|
||||
$storage->storeInterfaces($interfaceRegistry);
|
||||
$intDuration = round((microtime(true) - $intStart) * 1000, 2);
|
||||
echo " ✅ {$interfaceRegistry->count()} implementations in {$intDuration}ms\n\n";
|
||||
|
||||
// Summary
|
||||
$totalDuration = round((microtime(true) - $totalStart) * 1000, 2);
|
||||
echo str_repeat("=", 60) . "\n";
|
||||
echo "🎉 Discovery bootstrap complete in {$totalDuration}ms\n";
|
||||
echo " 📁 Stored in: storage/discovery/\n";
|
||||
echo str_repeat("=", 60) . "\n";
|
||||
Reference in New Issue
Block a user