Skip to main content
Topic: php7.4 preloading (Read 1104 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

php7.4 preloading

Is anyone using php7.4? Are you using preloading for elk? I'm interested in experimenting with preloading. Knowledge to pull it off is lacking. Apparently the initiation script must include an array of all php files in the script (here, elk) as well as appropriate classes and namespaces. Seems it may be a daunting task for the uh, lesser codeworthy. How difficult would this be?

Re: php7.4 preloading

Reply #1

Not sure. Haven't tried it yet.

Re: php7.4 preloading

Reply #2

Well, the "quick&dirty" way would be to take any file in sources, themes and the root and require_once all of them.
Only thing to pay attention should be the order to avoid issues, but if you start instantiating the bootstrap class and loading the autoloader, that should do most of the work.
It may be something like:
Code: [Select]

$forum_path = '/path/to/forum';
$root_files = [

function getFilesRecursive($dir, $ext = '.php')
$full_paths = array();

$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
$filter = new RegexIterator($iterator, '/' . preg_quote($ext) . '$/');

foreach ($filter as $path => $file)
if ($file->isDir() === false)
$full_paths[] = $path;

return $full_paths;

require_once($forum_path . '/bootstrap.php');
$source_files = getFilesRecursive($forum_path . '/sources');
$themes_files = getFilesRecursive($forum_path . '/themes');
foreach ($root_files as $k => $file)
$root_files[$k] = $forum_path . '/' . $root_files[$k];

foreach ([$source_files, $themes_files, $root_files] as $files)
foreach ($files as $file)

No idea if it works or not.