From 261700eabb03aab3415cc8117723b59ca550c346 Mon Sep 17 00:00:00 2001 From: "Joseph.Rawlings" Date: Sun, 21 Dec 2025 13:19:13 +0100 Subject: [PATCH] preload --- preload.php | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 preload.php 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();