-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathpreload.php
More file actions
50 lines (43 loc) · 1.43 KB
/
preload.php
File metadata and controls
50 lines (43 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* By connecting this script to php.ini, you can achieve an increase
* in the performance of the framework in opcache mode.
*
* Подключив этот скрипт в php.ini можно добиться прироста
* производительности фреймворка в режиме opcache.
*
* ```
* opcache.preload=/path/to/project/vendor/phphleb/framework/preload.php
* ```
*/
use Hleb\Init\Connectors\HlebConnector;
if (!class_exists(HlebConnector::class, false)) {
$dir = realpath(__DIR__);
include $dir . '/Init/Connectors/HlebConnector.php';
$map = HlebConnector::$map;
array_walk($map, function (&$path) use ($dir): void {
$path = $dir . $path;
});
if (!function_exists('search_root')) {
include $dir . '/Init/Connectors/Preload/search-functions.php';
}
$root = search_root();
foreach (HlebConnector::$bootstrapMap as $file) {
$map[] = $root . $file;
}
$routeDir = \realpath($root . '/storage/cache/routes');
if (is_dir($routeDir)) {
$map = array_merge($map, search_php_files($routeDir));
}
if (!function_exists('get_env')) {
$map[] = $dir . '/Init/Review/basic.php';
}
if (!function_exists('hl_debug')) {
$map[] = $dir . '/Init/Review/functions.php';
}
if (function_exists('opcache_compile_file')) {
foreach ($map as $file) {
@opcache_compile_file($file);
}
}
}