diff --git a/preload.php b/preload.php new file mode 100644 index 000000000..dc6fc5fd9 --- /dev/null +++ b/preload.php @@ -0,0 +1,103 @@ +getMethods() as $method) { + if ($method->isPublic() && !$method->isAbstract()) { + $method->getStaticVariables(); + } + } + + // Preload parent classes + $parent = $rc->getParentClass(); + if ($parent) { + preloadClass($parent->getName()); + } + + // Preload interfaces + foreach ($rc->getInterfaces() as $interface) { + preloadClass($interface->getName()); + } +} + +function preloadDirectory($dir, $pattern) { + if (!is_dir($dir)) { + return; + } + + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dir) + ); + + foreach ($iterator as $file) { + if ($file->isFile() && preg_match($pattern, $file->getPathname())) { + require_once $file->getPathname(); + } + } +} + +// Preload framework classes +foreach ($classesToPreload as $class) { + preloadClass($class); +} + +// Preload application directories +preloadDirectory(__DIR__ . '/app/Http/Controllers', '/\.php$/'); +preloadDirectory(__DIR__ . '/app/Models', '/\.php$/'); +preloadDirectory(__DIR__ . '/app/Jobs', '/\.php$/'); +preloadDirectory(__DIR__ . '/app/Providers', '/\.php$/'); + +// Free memory +gc_collect_cycles();