|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +function createDirectory(string $path): void |
| 6 | +{ |
| 7 | + if (!is_dir($path)) { |
| 8 | + mkdir($path, 0777, true); |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +function createFile(string $filePath): void |
| 13 | +{ |
| 14 | + $content = "<?php\n\ndeclare(strict_types=1);\n"; |
| 15 | + if (!file_exists($filePath)) { |
| 16 | + file_put_contents($filePath, $content); |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +$baseDir = __DIR__ . '/src'; |
| 21 | + |
| 22 | +// Directories and their respective files |
| 23 | +$structure = [ |
| 24 | + 'AbstractException.php', |
| 25 | + 'AbstractErrorMessage.php', |
| 26 | + 'Contract/ErrorMessage.php', |
| 27 | + 'Contract/Throwable.php', |
| 28 | + 'CommonErrorMessages.php', |
| 29 | + 'Auth/AuthenticationException.php', |
| 30 | + 'Auth/AuthorizationException.php', |
| 31 | + 'Validation/ValidationException.php', |
| 32 | + 'Validation/RuleViolationException.php', |
| 33 | + 'File/FileException.php', |
| 34 | + 'Input/InputException.php', |
| 35 | + 'Runtime/RuntimeException.php', |
| 36 | + 'System/SystemException.php', |
| 37 | + 'Security/SecurityException.php', |
| 38 | + 'Security/EncryptionException.php', |
| 39 | + 'Config/ConfigurationException.php', |
| 40 | + 'Network/NetworkException.php', |
| 41 | + 'Network/HttpException.php', |
| 42 | + 'Database/DatabaseException.php', |
| 43 | + 'Cache/CacheException.php', |
| 44 | + 'ExternalService/ExternalServiceException.php', |
| 45 | + 'Localization/LocalizationException.php', |
| 46 | + 'Event/EventException.php', |
| 47 | + 'Middleware/MiddlewareException.php', |
| 48 | + 'Queue/QueueException.php', |
| 49 | + 'Routing/RoutingException.php', |
| 50 | + 'Template/TemplateException.php', |
| 51 | + 'Session/SessionException.php', |
| 52 | + 'Container/ContainerException.php', |
| 53 | +]; |
| 54 | + |
| 55 | +// Create directories and files |
| 56 | +foreach ($structure as $filePath) { |
| 57 | + $fullPath = $baseDir . '/' . $filePath; |
| 58 | + $directory = dirname($fullPath); |
| 59 | + |
| 60 | + // Create the directory if it doesn't exist |
| 61 | + createDirectory($directory); |
| 62 | + |
| 63 | + // Create the file with the appropriate content |
| 64 | + createFile($fullPath); |
| 65 | +} |
| 66 | + |
| 67 | +echo "Directories and files created successfully!\n"; |
0 commit comments