|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DetectOpCodeCache; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* PHP Opcode-Cache detection |
|
7
|
|
|
* |
|
8
|
|
|
* @author Alexander Over <[email protected]> |
|
9
|
|
|
*/ |
|
10
|
|
|
final class DetectOpCodeCache |
|
11
|
|
|
{ |
|
12
|
|
|
final public static function checkAll() |
|
13
|
|
|
{ |
|
14
|
|
|
return (self::hasXcache() || |
|
15
|
|
|
self::hasWincache() || |
|
16
|
|
|
self::hasApc() || |
|
17
|
|
|
self::hasEaccelerator() || |
|
18
|
|
|
self::hasIoncube() || |
|
19
|
|
|
self::hasZend() || |
|
20
|
|
|
self::hasNusphere() || |
|
21
|
|
|
self::hasOpCode() |
|
22
|
|
|
); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* check if we have Xcache |
|
27
|
|
|
* |
|
28
|
|
|
* @link http://xcache.lighttpd.net |
|
29
|
|
|
* @return bool |
|
30
|
|
|
*/ |
|
31
|
|
|
public static function hasXcache() |
|
32
|
|
|
{ |
|
33
|
|
|
return function_exists('xcache_isset'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* check if we have Wincache |
|
38
|
|
|
* |
|
39
|
|
|
* @link http://www.iis.net/expand/WinCacheForPHP |
|
40
|
|
|
* @return bool |
|
41
|
|
|
*/ |
|
42
|
|
|
public static function hasWincache() |
|
43
|
|
|
{ |
|
44
|
|
|
return function_exists('wincache_fcache_fileinfo'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* check if we have Alternative PHP Cache |
|
49
|
|
|
* |
|
50
|
|
|
* @link http://pecl.php.net/package/apc |
|
51
|
|
|
* @return bool |
|
52
|
|
|
*/ |
|
53
|
|
|
public static function hasApc() |
|
54
|
|
|
{ |
|
55
|
|
|
return function_exists('apc_add'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* check if we have eAccelerator |
|
60
|
|
|
* |
|
61
|
|
|
* @link http://eaccelerator.net |
|
62
|
|
|
* @return bool |
|
63
|
|
|
*/ |
|
64
|
|
|
public static function hasEaccelerator() |
|
65
|
|
|
{ |
|
66
|
|
|
// !empty doesn't work, because no variable |
|
67
|
|
|
return (bool)strlen(ini_get('eaccelerator.enable')); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* check if we have ionCube Loader |
|
72
|
|
|
* |
|
73
|
|
|
* @link http://www.php-accelerator.co.uk |
|
74
|
|
|
* @return bool |
|
75
|
|
|
*/ |
|
76
|
|
|
public static function hasIoncube() |
|
77
|
|
|
{ |
|
78
|
|
|
return (bool)strlen(ini_get('phpa')); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* check if we have Zend Optimizer+ |
|
83
|
|
|
* |
|
84
|
|
|
* @link http://www.zend.com/products/server |
|
85
|
|
|
* @return bool |
|
86
|
|
|
*/ |
|
87
|
|
|
public static function hasZend() |
|
88
|
|
|
{ |
|
89
|
|
|
return (bool)strlen(ini_get('zend_optimizer.enable_loader')); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* check if we have nuSphere phpExpress |
|
94
|
|
|
* |
|
95
|
|
|
* @link http://www.nusphere.com/products/phpexpress.htm |
|
96
|
|
|
* @return bool |
|
97
|
|
|
*/ |
|
98
|
|
|
public static function hasNusphere() |
|
99
|
|
|
{ |
|
100
|
|
|
return function_exists('phpexpress'); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* check if we have php 5.5.5+ opcode cache |
|
105
|
|
|
* |
|
106
|
|
|
* @link http://php.net/manual/de/book.opcache.php |
|
107
|
|
|
* @return bool |
|
108
|
|
|
*/ |
|
109
|
|
|
public static function hasOpCode() |
|
110
|
|
|
{ |
|
111
|
|
|
return (bool)strlen(ini_get('opcache.enable')); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|