123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- require __DIR__ . '/app/Config/Paths.php';
- define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR);
- class preload
- {
-
- private array $paths = [
- [
- 'include' => __DIR__ . '/vendor/codeigniter4/framework/system',
- 'exclude' => [
- '/system/bootstrap.php',
-
- '/system/Database/OCI8/',
- '/system/Database/Postgre/',
- '/system/Database/SQLite3/',
- '/system/Database/SQLSRV/',
-
- '/system/Database/Seeder.php',
- '/system/Test/',
- '/system/Language/',
- '/system/CLI/',
- '/system/Commands/',
- '/system/Publisher/',
- '/system/ComposerScripts.php',
- '/Views/',
-
- '/system/Config/Routes.php',
- '/system/ThirdParty/',
- ],
- ],
- ];
- public function __construct()
- {
- $this->loadAutoloader();
- }
- private function loadAutoloader(): void
- {
- $paths = new Config\Paths();
- require rtrim($paths->systemDirectory, '\\/ ') . DIRECTORY_SEPARATOR . 'Boot.php';
- CodeIgniter\Boot::preload($paths);
- }
-
- public function load(): void
- {
- foreach ($this->paths as $path) {
- $directory = new RecursiveDirectoryIterator($path['include']);
- $fullTree = new RecursiveIteratorIterator($directory);
- $phpFiles = new RegexIterator(
- $fullTree,
- '/.+((?<!Test)+\.php$)/i',
- RecursiveRegexIterator::GET_MATCH
- );
- foreach ($phpFiles as $key => $file) {
- foreach ($path['exclude'] as $exclude) {
- if (str_contains($file[0], $exclude)) {
- continue 2;
- }
- }
- require_once $file[0];
- echo 'Loaded: ' . $file[0] . "\n";
- }
- }
- }
- }
- (new preload())->load();
|