FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CodeIgniter4/preload.php at develop · codeigniter4/CodeIgniter4 · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
codeigniter4
/
CodeIgniter4
Public
Notifications
You must be signed in to change notification settings
Fork
2k
Star
6k
Code
Issues
26
Pull requests
15
Actions
Security and quality
17
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
CodeIgniter4
/
preload.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
112 lines (99 loc) · 3.32 KB
Breadcrumbs
CodeIgniter4
/
preload.php
Copy path
File metadata and controls
112 lines (99 loc) · 3.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
use
CodeIgniter
\
Boot
;
use
Config
\
Paths
;
/*
*---------------------------------------------------------------
* Sample file for Preloading
*---------------------------------------------------------------
* See https://www.php.net/manual/en/opcache.preloading.php
*
* How to Use:
* 0. Copy this file to your project root folder.
* 1. Set the $paths property of the preload class below.
* 2. Set opcache.preload in php.ini.
* php.ini:
* opcache.preload=/path/to/preload.php
*/
// Load the paths config file
require
__DIR__
.
'
/app/Config/Paths.php
'
;
// Path to the front controller
define
(
'
FCPATH
'
,
__DIR__
.
DIRECTORY_SEPARATOR
.
'
public
'
.
DIRECTORY_SEPARATOR
);
class
preload
{
/**
* @var array Paths to preload.
*/
private
array
$
paths
= [
[
'
include
'
=>
__DIR__
.
'
/vendor/codeigniter4/framework/system
'
,
// Change this path if using manual installation
'
exclude
'
=> [
// Not needed if you don't use them.
'
/system/Database/OCI8/
'
,
'
/system/Database/Postgre/
'
,
'
/system/Database/SQLite3/
'
,
'
/system/Database/SQLSRV/
'
,
// Not needed for web apps.
'
/system/Database/Seeder.php
'
,
'
/system/Test/
'
,
'
/system/CLI/
'
,
'
/system/Commands/
'
,
'
/system/Publisher/
'
,
'
/system/ComposerScripts.php
'
,
// Not Class/Function files.
'
/system/Config/Routes.php
'
,
'
/system/Language/
'
,
'
/system/bootstrap.php
'
,
'
/system/util_bootstrap.php
'
,
'
/system/rewrite.php
'
,
'
/Views/
'
,
// Errors occur.
'
/system/ThirdParty/
'
,
],
],
];
public
function
__construct
()
{
$
this
->
loadAutoloader
();
}
private
function
loadAutoloader
():
void
{
$
paths
=
new
Paths
();
require
rtrim
(
$
paths
->
systemDirectory
,
'\\
/
'
) .
DIRECTORY_SEPARATOR
.
'
Boot.php
'
;
Boot::
preload
(
$
paths
);
}
/**
* Load PHP files.
*/
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
];
// Uncomment only for debugging (to inspect which files are included).
// Never use this in production - preload scripts must not generate output.
// echo 'Loaded: ' . $file[0] . "\n";
}
}
}
}
(
new
preload
())->
load
();
Back
|
FazBrowse Home
|
New Git URL