|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Symfony package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Fabien Potencier <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/* |
|
13
|
|
|
* Users of PHP 5.2 should be able to run the requirements checks. |
|
14
|
|
|
* This is why the file and all classes must be compatible with PHP 5.2+ |
|
15
|
|
|
* (e.g. not using namespaces and closures). |
|
16
|
|
|
* |
|
17
|
|
|
* ************** CAUTION ************** |
|
18
|
|
|
* |
|
19
|
|
|
* DO NOT EDIT THIS FILE as it will be overriden by Composer as part of |
|
20
|
|
|
* the installation/update process. The original file resides in the |
|
21
|
|
|
* SensioDistributionBundle. |
|
22
|
|
|
* |
|
23
|
|
|
* ************** CAUTION ************** |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Represents a single PHP requirement, e.g. an installed extension. |
|
28
|
|
|
* It can be a mandatory requirement or an optional recommendation. |
|
29
|
|
|
* There is a special subclass, named PhpIniRequirement, to check a php.ini configuration. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Tobias Schultze <http://tobion.de> |
|
32
|
|
|
*/ |
|
33
|
|
|
class Requirement |
|
34
|
|
|
{ |
|
35
|
|
|
private $fulfilled; |
|
36
|
|
|
private $testMessage; |
|
37
|
|
|
private $helpText; |
|
38
|
|
|
private $helpHtml; |
|
39
|
|
|
private $optional; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Constructor that initializes the requirement. |
|
43
|
|
|
* |
|
44
|
|
|
* @param Boolean $fulfilled Whether the requirement is fulfilled |
|
45
|
|
|
* @param string $testMessage The message for testing the requirement |
|
46
|
|
|
* @param string $helpHtml The help text formatted in HTML for resolving the problem |
|
47
|
|
|
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
|
48
|
|
|
* @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement |
|
49
|
|
|
*/ |
|
50
|
|
|
public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->fulfilled = (Boolean) $fulfilled; |
|
53
|
|
|
$this->testMessage = (string) $testMessage; |
|
54
|
|
|
$this->helpHtml = (string) $helpHtml; |
|
55
|
|
|
$this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; |
|
56
|
|
|
$this->optional = (Boolean) $optional; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Returns whether the requirement is fulfilled. |
|
61
|
|
|
* |
|
62
|
|
|
* @return Boolean true if fulfilled, otherwise false |
|
63
|
|
|
*/ |
|
64
|
|
|
public function isFulfilled() |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->fulfilled; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Returns the message for testing the requirement. |
|
71
|
|
|
* |
|
72
|
|
|
* @return string The test message |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getTestMessage() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->testMessage; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Returns the help text for resolving the problem |
|
81
|
|
|
* |
|
82
|
|
|
* @return string The help text |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getHelpText() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->helpText; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Returns the help text formatted in HTML. |
|
91
|
|
|
* |
|
92
|
|
|
* @return string The HTML help |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getHelpHtml() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->helpHtml; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Returns whether this is only an optional recommendation and not a mandatory requirement. |
|
101
|
|
|
* |
|
102
|
|
|
* @return Boolean true if optional, false if mandatory |
|
103
|
|
|
*/ |
|
104
|
|
|
public function isOptional() |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->optional; |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Represents a PHP requirement in form of a php.ini configuration. |
|
112
|
|
|
* |
|
113
|
|
|
* @author Tobias Schultze <http://tobion.de> |
|
114
|
|
|
*/ |
|
115
|
|
|
class PhpIniRequirement extends Requirement |
|
116
|
|
|
{ |
|
117
|
|
|
/** |
|
118
|
|
|
* Constructor that initializes the requirement. |
|
119
|
|
|
* |
|
120
|
|
|
* @param string $cfgName The configuration name used for ini_get() |
|
121
|
|
|
* @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, |
|
122
|
|
|
or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement |
|
123
|
|
|
* @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. |
|
124
|
|
|
This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. |
|
125
|
|
|
Example: You require a config to be true but PHP later removes this config and defaults it to true internally. |
|
126
|
|
|
* @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) |
|
127
|
|
|
* @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) |
|
128
|
|
|
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
|
129
|
|
|
* @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement |
|
130
|
|
|
*/ |
|
131
|
|
|
public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) |
|
132
|
|
|
{ |
|
133
|
|
|
$cfgValue = ini_get($cfgName); |
|
134
|
|
|
|
|
135
|
|
|
if (is_callable($evaluation)) { |
|
136
|
|
|
if (null === $testMessage || null === $helpHtml) { |
|
137
|
|
|
throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
$fulfilled = call_user_func($evaluation, $cfgValue); |
|
141
|
|
|
} else { |
|
142
|
|
|
if (null === $testMessage) { |
|
143
|
|
|
$testMessage = sprintf('%s %s be %s in php.ini', |
|
144
|
|
|
$cfgName, |
|
145
|
|
|
$optional ? 'should' : 'must', |
|
146
|
|
|
$evaluation ? 'enabled' : 'disabled' |
|
147
|
|
|
); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
if (null === $helpHtml) { |
|
151
|
|
|
$helpHtml = sprintf('Set <strong>%s</strong> to <strong>%s</strong> in php.ini<a href="#phpini">*</a>.', |
|
152
|
|
|
$cfgName, |
|
153
|
|
|
$evaluation ? 'on' : 'off' |
|
154
|
|
|
); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
$fulfilled = $evaluation == $cfgValue; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
parent::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional); |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* A RequirementCollection represents a set of Requirement instances. |
|
166
|
|
|
* |
|
167
|
|
|
* @author Tobias Schultze <http://tobion.de> |
|
168
|
|
|
*/ |
|
169
|
|
|
class RequirementCollection implements IteratorAggregate |
|
170
|
|
|
{ |
|
171
|
|
|
private $requirements = array(); |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Gets the current RequirementCollection as an Iterator. |
|
175
|
|
|
* |
|
176
|
|
|
* @return Traversable A Traversable interface |
|
177
|
|
|
*/ |
|
178
|
|
|
public function getIterator() |
|
179
|
|
|
{ |
|
180
|
|
|
return new ArrayIterator($this->requirements); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* Adds a Requirement. |
|
185
|
|
|
* |
|
186
|
|
|
* @param Requirement $requirement A Requirement instance |
|
187
|
|
|
*/ |
|
188
|
|
|
public function add(Requirement $requirement) |
|
189
|
|
|
{ |
|
190
|
|
|
$this->requirements[] = $requirement; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* Adds a mandatory requirement. |
|
195
|
|
|
* |
|
196
|
|
|
* @param Boolean $fulfilled Whether the requirement is fulfilled |
|
197
|
|
|
* @param string $testMessage The message for testing the requirement |
|
198
|
|
|
* @param string $helpHtml The help text formatted in HTML for resolving the problem |
|
199
|
|
|
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
|
200
|
|
|
*/ |
|
201
|
|
|
public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null) |
|
202
|
|
|
{ |
|
203
|
|
|
$this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false)); |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Adds an optional recommendation. |
|
208
|
|
|
* |
|
209
|
|
|
* @param Boolean $fulfilled Whether the recommendation is fulfilled |
|
210
|
|
|
* @param string $testMessage The message for testing the recommendation |
|
211
|
|
|
* @param string $helpHtml The help text formatted in HTML for resolving the problem |
|
212
|
|
|
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
|
213
|
|
|
*/ |
|
214
|
|
|
public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null) |
|
215
|
|
|
{ |
|
216
|
|
|
$this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true)); |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Adds a mandatory requirement in form of a php.ini configuration. |
|
221
|
|
|
* |
|
222
|
|
|
* @param string $cfgName The configuration name used for ini_get() |
|
223
|
|
|
* @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, |
|
224
|
|
|
or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement |
|
225
|
|
|
* @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. |
|
226
|
|
|
This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. |
|
227
|
|
|
Example: You require a config to be true but PHP later removes this config and defaults it to true internally. |
|
228
|
|
|
* @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) |
|
229
|
|
|
* @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) |
|
230
|
|
|
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
|
231
|
|
|
*/ |
|
232
|
|
|
public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) |
|
233
|
|
|
{ |
|
234
|
|
|
$this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false)); |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* Adds an optional recommendation in form of a php.ini configuration. |
|
239
|
|
|
* |
|
240
|
|
|
* @param string $cfgName The configuration name used for ini_get() |
|
241
|
|
|
* @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, |
|
242
|
|
|
or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement |
|
243
|
|
|
* @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. |
|
244
|
|
|
This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. |
|
245
|
|
|
Example: You require a config to be true but PHP later removes this config and defaults it to true internally. |
|
246
|
|
|
* @param string $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) |
|
247
|
|
|
* @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) |
|
248
|
|
|
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
|
249
|
|
|
*/ |
|
250
|
|
|
public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) |
|
251
|
|
|
{ |
|
252
|
|
|
$this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true)); |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* Adds a requirement collection to the current set of requirements. |
|
257
|
|
|
* |
|
258
|
|
|
* @param RequirementCollection $collection A RequirementCollection instance |
|
259
|
|
|
*/ |
|
260
|
|
|
public function addCollection(RequirementCollection $collection) |
|
261
|
|
|
{ |
|
262
|
|
|
$this->requirements = array_merge($this->requirements, $collection->all()); |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* Returns both requirements and recommendations. |
|
267
|
|
|
* |
|
268
|
|
|
* @return array Array of Requirement instances |
|
269
|
|
|
*/ |
|
270
|
|
|
public function all() |
|
271
|
|
|
{ |
|
272
|
|
|
return $this->requirements; |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
/** |
|
276
|
|
|
* Returns all mandatory requirements. |
|
277
|
|
|
* |
|
278
|
|
|
* @return array Array of Requirement instances |
|
279
|
|
|
*/ |
|
280
|
|
|
public function getRequirements() |
|
281
|
|
|
{ |
|
282
|
|
|
$array = array(); |
|
283
|
|
|
foreach ($this->requirements as $req) { |
|
284
|
|
|
if (!$req->isOptional()) { |
|
285
|
|
|
$array[] = $req; |
|
286
|
|
|
} |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
return $array; |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* Returns the mandatory requirements that were not met. |
|
294
|
|
|
* |
|
295
|
|
|
* @return array Array of Requirement instances |
|
296
|
|
|
*/ |
|
297
|
|
|
public function getFailedRequirements() |
|
298
|
|
|
{ |
|
299
|
|
|
$array = array(); |
|
300
|
|
|
foreach ($this->requirements as $req) { |
|
301
|
|
|
if (!$req->isFulfilled() && !$req->isOptional()) { |
|
302
|
|
|
$array[] = $req; |
|
303
|
|
|
} |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
return $array; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* Returns all optional recommmendations. |
|
311
|
|
|
* |
|
312
|
|
|
* @return array Array of Requirement instances |
|
313
|
|
|
*/ |
|
314
|
|
|
public function getRecommendations() |
|
315
|
|
|
{ |
|
316
|
|
|
$array = array(); |
|
317
|
|
|
foreach ($this->requirements as $req) { |
|
318
|
|
|
if ($req->isOptional()) { |
|
319
|
|
|
$array[] = $req; |
|
320
|
|
|
} |
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
return $array; |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* Returns the recommendations that were not met. |
|
328
|
|
|
* |
|
329
|
|
|
* @return array Array of Requirement instances |
|
330
|
|
|
*/ |
|
331
|
|
|
public function getFailedRecommendations() |
|
332
|
|
|
{ |
|
333
|
|
|
$array = array(); |
|
334
|
|
|
foreach ($this->requirements as $req) { |
|
335
|
|
|
if (!$req->isFulfilled() && $req->isOptional()) { |
|
336
|
|
|
$array[] = $req; |
|
337
|
|
|
} |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
return $array; |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
/** |
|
344
|
|
|
* Returns whether a php.ini configuration is not correct. |
|
345
|
|
|
* |
|
346
|
|
|
* @return Boolean php.ini configuration problem? |
|
347
|
|
|
*/ |
|
348
|
|
|
public function hasPhpIniConfigIssue() |
|
349
|
|
|
{ |
|
350
|
|
|
foreach ($this->requirements as $req) { |
|
351
|
|
|
if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) { |
|
352
|
|
|
return true; |
|
353
|
|
|
} |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
return false; |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
/** |
|
360
|
|
|
* Returns the PHP configuration file (php.ini) path. |
|
361
|
|
|
* |
|
362
|
|
|
* @return string|false php.ini file path |
|
363
|
|
|
*/ |
|
364
|
|
|
public function getPhpIniConfigPath() |
|
365
|
|
|
{ |
|
366
|
|
|
return get_cfg_var('cfg_file_path'); |
|
367
|
|
|
} |
|
368
|
|
|
} |
|
369
|
|
|
|
|
370
|
|
|
/** |
|
371
|
|
|
* This class specifies all requirements and optional recommendations that |
|
372
|
|
|
* are necessary to run the Symfony Standard Edition. |
|
373
|
|
|
* |
|
374
|
|
|
* @author Tobias Schultze <http://tobion.de> |
|
375
|
|
|
* @author Fabien Potencier <[email protected]> |
|
376
|
|
|
*/ |
|
377
|
|
|
class SymfonyRequirements extends RequirementCollection |
|
378
|
|
|
{ |
|
379
|
|
|
const REQUIRED_PHP_VERSION = '5.3.3'; |
|
380
|
|
|
|
|
381
|
|
|
/** |
|
382
|
|
|
* Constructor that initializes the requirements. |
|
383
|
|
|
*/ |
|
384
|
|
|
public function __construct() |
|
385
|
|
|
{ |
|
386
|
|
|
/* mandatory requirements follow */ |
|
387
|
|
|
|
|
388
|
|
|
$installedPhpVersion = phpversion(); |
|
389
|
|
|
|
|
390
|
|
|
$this->addRequirement( |
|
391
|
|
|
version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), |
|
392
|
|
|
sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), |
|
393
|
|
|
sprintf('You are running PHP version "<strong>%s</strong>", but Symfony needs at least PHP "<strong>%s</strong>" to run. |
|
394
|
|
|
Before using Symfony, upgrade your PHP installation, preferably to the latest version.', |
|
395
|
|
|
$installedPhpVersion, self::REQUIRED_PHP_VERSION), |
|
396
|
|
|
sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion) |
|
397
|
|
|
); |
|
398
|
|
|
|
|
399
|
|
|
$this->addRequirement( |
|
400
|
|
|
version_compare($installedPhpVersion, '5.3.16', '!='), |
|
401
|
|
|
'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', |
|
402
|
|
|
'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' |
|
403
|
|
|
); |
|
404
|
|
|
|
|
405
|
|
|
$this->addRequirement( |
|
406
|
|
|
is_dir(__DIR__.'/../vendor/composer'), |
|
407
|
|
|
'Vendor libraries must be installed', |
|
408
|
|
|
'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. ' . |
|
409
|
|
|
'Then run "<strong>php composer.phar install</strong>" to install them.' |
|
410
|
|
|
); |
|
411
|
|
|
|
|
412
|
|
|
$baseDir = basename(__DIR__); |
|
413
|
|
|
|
|
414
|
|
|
$this->addRequirement( |
|
415
|
|
|
is_writable(__DIR__.'/cache'), |
|
416
|
|
|
"$baseDir/cache/ directory must be writable", |
|
417
|
|
|
"Change the permissions of the \"<strong>$baseDir/cache/</strong>\" directory so that the web server can write into it." |
|
418
|
|
|
); |
|
419
|
|
|
|
|
420
|
|
|
$this->addRequirement( |
|
421
|
|
|
is_writable(__DIR__.'/logs'), |
|
422
|
|
|
"$baseDir/logs/ directory must be writable", |
|
423
|
|
|
"Change the permissions of the \"<strong>$baseDir/logs/</strong>\" directory so that the web server can write into it." |
|
424
|
|
|
); |
|
425
|
|
|
|
|
426
|
|
|
$this->addPhpIniRequirement( |
|
427
|
|
|
'date.timezone', true, false, |
|
428
|
|
|
'date.timezone setting must be set', |
|
429
|
|
|
'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).' |
|
430
|
|
|
); |
|
431
|
|
|
|
|
432
|
|
|
if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { |
|
433
|
|
|
$this->addRequirement( |
|
434
|
|
|
(in_array(date_default_timezone_get(), DateTimeZone::listIdentifiers())), |
|
435
|
|
|
sprintf('Configured default timezone "%s" must be supported by your installation of PHP', date_default_timezone_get()), |
|
436
|
|
|
'Your default timezone is not supported by PHP. Check for typos in your <strong>php.ini</strong> file and have a look at the list of deprecated timezones at <a href="http://php.net/manual/en/timezones.others.php">http://php.net/manual/en/timezones.others.php</a>.' |
|
437
|
|
|
); |
|
438
|
|
|
} |
|
439
|
|
|
|
|
440
|
|
|
$this->addRequirement( |
|
441
|
|
|
function_exists('json_encode'), |
|
442
|
|
|
'json_encode() must be available', |
|
443
|
|
|
'Install and enable the <strong>JSON</strong> extension.' |
|
444
|
|
|
); |
|
445
|
|
|
|
|
446
|
|
|
$this->addRequirement( |
|
447
|
|
|
function_exists('session_start'), |
|
448
|
|
|
'session_start() must be available', |
|
449
|
|
|
'Install and enable the <strong>session</strong> extension.' |
|
450
|
|
|
); |
|
451
|
|
|
|
|
452
|
|
|
$this->addRequirement( |
|
453
|
|
|
function_exists('ctype_alpha'), |
|
454
|
|
|
'ctype_alpha() must be available', |
|
455
|
|
|
'Install and enable the <strong>ctype</strong> extension.' |
|
456
|
|
|
); |
|
457
|
|
|
|
|
458
|
|
|
$this->addRequirement( |
|
459
|
|
|
function_exists('token_get_all'), |
|
460
|
|
|
'token_get_all() must be available', |
|
461
|
|
|
'Install and enable the <strong>Tokenizer</strong> extension.' |
|
462
|
|
|
); |
|
463
|
|
|
|
|
464
|
|
|
$this->addRequirement( |
|
465
|
|
|
function_exists('simplexml_import_dom'), |
|
466
|
|
|
'simplexml_import_dom() must be available', |
|
467
|
|
|
'Install and enable the <strong>SimpleXML</strong> extension.' |
|
468
|
|
|
); |
|
469
|
|
|
|
|
470
|
|
|
if (function_exists('apc_store') && ini_get('apc.enabled')) { |
|
471
|
|
|
$this->addRequirement( |
|
472
|
|
|
version_compare(phpversion('apc'), '3.0.17', '>='), |
|
473
|
|
|
'APC version must be at least 3.0.17', |
|
474
|
|
|
'Upgrade your <strong>APC</strong> extension (3.0.17+).' |
|
475
|
|
|
); |
|
476
|
|
|
} |
|
477
|
|
|
|
|
478
|
|
|
$this->addPhpIniRequirement('detect_unicode', false); |
|
479
|
|
|
|
|
480
|
|
|
ob_start(); |
|
481
|
|
|
phpinfo(); |
|
482
|
|
|
$phpinfo = ob_get_contents(); |
|
483
|
|
|
ob_end_clean(); |
|
484
|
|
|
|
|
485
|
|
|
// the phpinfo check is necessary when Suhosin is compiled into PHP |
|
486
|
|
|
if (extension_loaded('suhosin') || false !== strpos($phpinfo, 'Suhosin')) { |
|
487
|
|
|
$this->addPhpIniRequirement( |
|
488
|
|
|
'suhosin.executor.include.whitelist', |
|
489
|
|
|
create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), |
|
490
|
|
|
false, |
|
491
|
|
|
'suhosin.executor.include.whitelist must be configured correctly in php.ini', |
|
492
|
|
|
'Add "<strong>phar</strong>" to <strong>suhosin.executor.include.whitelist</strong> in php.ini<a href="#phpini">*</a>.' |
|
493
|
|
|
); |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
if (extension_loaded('xdebug')) { |
|
497
|
|
|
$this->addPhpIniRequirement( |
|
498
|
|
|
'xdebug.show_exception_trace', false, true |
|
499
|
|
|
); |
|
500
|
|
|
|
|
501
|
|
|
$this->addPhpIniRequirement( |
|
502
|
|
|
'xdebug.scream', false, true |
|
503
|
|
|
); |
|
504
|
|
|
} |
|
505
|
|
|
|
|
506
|
|
|
$pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; |
|
507
|
|
|
|
|
508
|
|
|
$this->addRequirement( |
|
509
|
|
|
null !== $pcreVersion && $pcreVersion > 8.0, |
|
510
|
|
|
sprintf('PCRE extension must be available and at least 8.0 (%s installed)', $pcreVersion ? $pcreVersion : 'not'), |
|
511
|
|
|
'Upgrade your <strong>PCRE</strong> extension (8.0+).' |
|
512
|
|
|
); |
|
513
|
|
|
|
|
514
|
|
|
/* optional recommendations follow */ |
|
515
|
|
|
|
|
516
|
|
|
$this->addRecommendation( |
|
517
|
|
|
file_get_contents(__FILE__) === file_get_contents(__DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'), |
|
518
|
|
|
'Requirements file should be up-to-date', |
|
519
|
|
|
'Your requirements file is outdated. Run composer install and re-check your configuration.' |
|
520
|
|
|
); |
|
521
|
|
|
|
|
522
|
|
|
$this->addRecommendation( |
|
523
|
|
|
version_compare($installedPhpVersion, '5.3.4', '>='), |
|
524
|
|
|
'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', |
|
525
|
|
|
'Your project might malfunction randomly due to PHP bug #52083 ("Notice: Trying to get property of non-object"). Install PHP 5.3.4 or newer.' |
|
526
|
|
|
); |
|
527
|
|
|
|
|
528
|
|
|
$this->addRecommendation( |
|
529
|
|
|
version_compare($installedPhpVersion, '5.3.8', '>='), |
|
530
|
|
|
'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', |
|
531
|
|
|
'Install PHP 5.3.8 or newer if your project uses annotations.' |
|
532
|
|
|
); |
|
533
|
|
|
|
|
534
|
|
|
$this->addRecommendation( |
|
535
|
|
|
version_compare($installedPhpVersion, '5.4.0', '!='), |
|
536
|
|
|
'You should not use PHP 5.4.0 due to the PHP bug #61453', |
|
537
|
|
|
'Your project might not work properly due to the PHP bug #61453 ("Cannot dump definitions which have method calls"). Install PHP 5.4.1 or newer.' |
|
538
|
|
|
); |
|
539
|
|
|
|
|
540
|
|
|
$this->addRecommendation( |
|
541
|
|
|
class_exists('DomDocument'), |
|
542
|
|
|
'PHP-XML module should be installed', |
|
543
|
|
|
'Install and enable the <strong>PHP-XML</strong> module.' |
|
544
|
|
|
); |
|
545
|
|
|
|
|
546
|
|
|
$this->addRecommendation( |
|
547
|
|
|
function_exists('mb_strlen'), |
|
548
|
|
|
'mb_strlen() should be available', |
|
549
|
|
|
'Install and enable the <strong>mbstring</strong> extension.' |
|
550
|
|
|
); |
|
551
|
|
|
|
|
552
|
|
|
$this->addRecommendation( |
|
553
|
|
|
function_exists('iconv'), |
|
554
|
|
|
'iconv() should be available', |
|
555
|
|
|
'Install and enable the <strong>iconv</strong> extension.' |
|
556
|
|
|
); |
|
557
|
|
|
|
|
558
|
|
|
$this->addRecommendation( |
|
559
|
|
|
function_exists('utf8_decode'), |
|
560
|
|
|
'utf8_decode() should be available', |
|
561
|
|
|
'Install and enable the <strong>XML</strong> extension.' |
|
562
|
|
|
); |
|
563
|
|
|
|
|
564
|
|
|
if (!defined('PHP_WINDOWS_VERSION_BUILD')) { |
|
565
|
|
|
$this->addRecommendation( |
|
566
|
|
|
function_exists('posix_isatty'), |
|
567
|
|
|
'posix_isatty() should be available', |
|
568
|
|
|
'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).' |
|
569
|
|
|
); |
|
570
|
|
|
} |
|
571
|
|
|
|
|
572
|
|
|
$this->addRecommendation( |
|
573
|
|
|
class_exists('Locale'), |
|
574
|
|
|
'intl extension should be available', |
|
575
|
|
|
'Install and enable the <strong>intl</strong> extension (used for validators).' |
|
576
|
|
|
); |
|
577
|
|
|
|
|
578
|
|
|
if (class_exists('Collator')) { |
|
579
|
|
|
$this->addRecommendation( |
|
580
|
|
|
null !== new Collator('fr_FR'), |
|
581
|
|
|
'intl extension should be correctly configured', |
|
582
|
|
|
'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.' |
|
583
|
|
|
); |
|
584
|
|
|
} |
|
585
|
|
|
|
|
586
|
|
|
if (class_exists('Locale')) { |
|
587
|
|
|
if (defined('INTL_ICU_VERSION')) { |
|
588
|
|
|
$version = INTL_ICU_VERSION; |
|
589
|
|
|
} else { |
|
590
|
|
|
$reflector = new ReflectionExtension('intl'); |
|
591
|
|
|
|
|
592
|
|
|
ob_start(); |
|
593
|
|
|
$reflector->info(); |
|
594
|
|
|
$output = strip_tags(ob_get_clean()); |
|
595
|
|
|
|
|
596
|
|
|
preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); |
|
597
|
|
|
$version = $matches[1]; |
|
598
|
|
|
} |
|
599
|
|
|
|
|
600
|
|
|
$this->addRecommendation( |
|
601
|
|
|
version_compare($version, '4.0', '>='), |
|
602
|
|
|
'intl ICU version should be at least 4+', |
|
603
|
|
|
'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).' |
|
604
|
|
|
); |
|
605
|
|
|
} |
|
606
|
|
|
|
|
607
|
|
|
$accelerator = |
|
608
|
|
|
(function_exists('apc_store') && ini_get('apc.enabled')) |
|
609
|
|
|
|| |
|
610
|
|
|
function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') |
|
611
|
|
|
|| |
|
612
|
|
|
function_exists('xcache_set') |
|
613
|
|
|
; |
|
614
|
|
|
|
|
615
|
|
|
$this->addRecommendation( |
|
616
|
|
|
$accelerator, |
|
617
|
|
|
'a PHP accelerator should be installed', |
|
618
|
|
|
'Install and enable a <strong>PHP accelerator</strong> like APC (highly recommended).' |
|
619
|
|
|
); |
|
620
|
|
|
|
|
621
|
|
|
$this->addPhpIniRecommendation('short_open_tag', false); |
|
622
|
|
|
|
|
623
|
|
|
$this->addPhpIniRecommendation('magic_quotes_gpc', false, true); |
|
624
|
|
|
|
|
625
|
|
|
$this->addPhpIniRecommendation('register_globals', false, true); |
|
626
|
|
|
|
|
627
|
|
|
$this->addPhpIniRecommendation('session.auto_start', false); |
|
628
|
|
|
|
|
629
|
|
|
$this->addRecommendation( |
|
630
|
|
|
class_exists('PDO'), |
|
631
|
|
|
'PDO should be installed', |
|
632
|
|
|
'Install <strong>PDO</strong> (mandatory for Doctrine).' |
|
633
|
|
|
); |
|
634
|
|
|
|
|
635
|
|
|
if (class_exists('PDO')) { |
|
636
|
|
|
$drivers = PDO::getAvailableDrivers(); |
|
637
|
|
|
$this->addRecommendation( |
|
638
|
|
|
count($drivers), |
|
639
|
|
|
sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), |
|
640
|
|
|
'Install <strong>PDO drivers</strong> (mandatory for Doctrine).' |
|
641
|
|
|
); |
|
642
|
|
|
} |
|
643
|
|
|
} |
|
644
|
|
|
} |
|
645
|
|
|
|