/
yiirequirementchecker.txt
261 lines (179 loc) · 6.2 KB
/
yiirequirementchecker.txt
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
*YiiRequirementChecker*
=======================
DESCRIPTION
------------------------------------------------------------------------------
This class allows rendering of the check report for the web and console
application interface.
Example:
require_once 'path/to/YiiRequirementChecker.php';
$requirementsChecker = new YiiRequirementChecker();
$requirements = array(
array(
'name' => 'PHP Some Extension',
'mandatory' => true,
'condition' => extension_loaded('some_extension'),
'by' => 'Some application feature',
'memo' => 'PHP extension "some_extension" required',
),
);
$requirementsChecker->checkYii()->check($requirements)->render();
If you wish to render the report with your own representation, use
'getResult()' instead of 'render()'
Requirement condition could be in format "eval:PHP expression". In this case
specified PHP expression will be evaluated in the context of this class
instance. For example:
$requirements = array(
array(
'name' => 'Upload max file size',
'condition' => 'eval:$this->checkUploadMaxFileSize("5M")',
),
);
Note: this class definition does not match ordinary Yii style, because it
should match PHP 4.3 and should not use features from newer PHP versions!
METHOD DETAILS
------------------------------------------------------------------------------
*YiiRequirementChecker::check* public
>
check($requirements)
<
return ($this) Self instance.
Check the given requirements, collecting results into internal field.
This method can be invoked several times checking different requirement sets.
Use 'getResult()' or 'render()' to get the results.
[$requirements] (array|string) Requirements to be checked. If an array, it
is treated as the set of requirements; If a string, it is treated as the
path of the file, which contains the requirements;
*YiiRequirementChecker::checkYii* public
>
checkYii()
<
return (\YiiRequirementChecker) Self instance.
Performs the check for the Yii core requirements.
*YiiRequirementChecker::getResult* public
>
getResult()
<
return (array|null) Check results in format:
array(
'summary' => array(
'total' => total number of checks,
'errors' => number of errors,
'warnings' => number of warnings,
),
'requirements' => array(
array(
...
'error' => is there an error,
'warning' => is there a warning,
),
...
),
)
Return the check results.
*YiiRequirementChecker::render* public
>
render()
<
return (void)
Renders the requirements check result.
The output will vary depending is a script running from web or from console.
*YiiRequirementChecker::checkPhpExtensionVersion* public
>
checkPhpExtensionVersion($extensionName, $version, $compare=''>='')
<
return (bool) If PHP extension version matches.
Checks if the given PHP extension is available and its version matches the
given one.
[$extensionName] (string) PHP extension name.
[$version] (string) Required PHP extension version.
[$compare] (string) Comparison operator, by default '>='
*YiiRequirementChecker::checkPhpIniOn* public
>
checkPhpIniOn($name)
<
return (bool) Option is on.
Checks if PHP configuration option (from php.ini) is on.
[$name] (string) Configuration option name.
*YiiRequirementChecker::checkPhpIniOff* public
>
checkPhpIniOff($name)
<
return (bool) Option is off.
Checks if PHP configuration option (from php.ini) is off.
[$name] (string) Configuration option name.
*YiiRequirementChecker::compareByteSize* public
>
compareByteSize($a, $b, $compare=''>='')
<
return (bool) Comparison result.
Compare byte sizes of values given in the verbose representation, like '5M',
'15K' etc.
[$a] (string) First value.
[$b] (string) Second value.
[$compare] (string) Comparison operator, by default '>='.
*YiiRequirementChecker::getByteSize* public
>
getByteSize($verboseSize)
<
return (int) Actual size in bytes.
Gets the size in bytes from verbose size representation.
For example: '5K' => 5*1024
[$verboseSize] (string) Verbose size representation.
*YiiRequirementChecker::checkUploadMaxFileSize* public
>
checkUploadMaxFileSize($min='null', $max='null')
<
return (bool) Success.
Checks if upload max file size matches the given range.
[$min] (string|null) Verbose file size minimum required value, pass null
to skip minimum check.
[$max] (string|null) Verbose file size maximum required value, pass null
to skip maximum check.
*YiiRequirementChecker::renderViewFile* public
>
renderViewFile($_viewFile_, $_data_='null', $_return_='false')
<
return (string) The rendering result. Null if the rendering result is not required.
Renders a view file.
This method includes the view file as a PHP script and captures the display
result if required.
[$_viewFile_] (string) View file
[$_data_] (array) Data to be extracted and made available to the view file
[$_return_] (bool) Whether the rendering result should be returned as a
string
*YiiRequirementChecker::normalizeRequirement* public
>
normalizeRequirement($requirement, $requirementKey=0)
<
return (array) Normalized requirement.
Normalizes requirement ensuring it has correct format.
[$requirement] (array) Raw requirement.
[$requirementKey] (int) Requirement key in the list.
*YiiRequirementChecker::usageError* public
>
usageError($message)
<
return (void)
Displays a usage error.
This method will then terminate the execution of the current application.
[$message] (string) The error message
*YiiRequirementChecker::evaluateExpression* public
>
evaluateExpression($expression)
<
return (mixed) The expression result.
Evaluates a PHP expression under the context of this class.
[$expression] (string) A PHP expression to be evaluated.
*YiiRequirementChecker::getServerInfo* public
>
getServerInfo()
<
return (string) Server information.
Returns the server information.
*YiiRequirementChecker::getNowDate* public
>
getNowDate()
<
return (string) Now date.
Returns the now date if possible in string representation.
vim:tw=78:ts=8:ft=help:norl: