4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
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).
17 * ************** CAUTION **************
19 * DO NOT EDIT THIS FILE as it will be overridden by Composer as part of
20 * the installation/update process. The original file resides in the
21 * SensioDistributionBundle.
23 * ************** CAUTION **************
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.
31 * @author Tobias Schultze <http://tobion.de>
42 * Constructor that initializes the requirement.
44 * @param bool $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 bool $optional Whether this is only an optional recommendation not a mandatory requirement
50 public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false)
52 $this->fulfilled
= (bool) $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
= (bool) $optional;
60 * Returns whether the requirement is fulfilled.
62 * @return bool true if fulfilled, otherwise false
64 public function isFulfilled()
66 return $this->fulfilled
;
70 * Returns the message for testing the requirement.
72 * @return string The test message
74 public function getTestMessage()
76 return $this->testMessage
;
80 * Returns the help text for resolving the problem.
82 * @return string The help text
84 public function getHelpText()
86 return $this->helpText
;
90 * Returns the help text formatted in HTML.
92 * @return string The HTML help
94 public function getHelpHtml()
96 return $this->helpHtml
;
100 * Returns whether this is only an optional recommendation and not a mandatory requirement.
102 * @return bool true if optional, false if mandatory
104 public function isOptional()
106 return $this->optional
;
111 * Represents a PHP requirement in form of a php.ini configuration.
113 * @author Tobias Schultze <http://tobion.de>
115 class PhpIniRequirement
extends Requirement
118 * Constructor that initializes the requirement.
120 * @param string $cfgName The configuration name used for ini_get()
121 * @param bool|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 bool $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 bool $optional Whether this is only an optional recommendation not a mandatory requirement
131 public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false)
133 $cfgValue = ini_get($cfgName);
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.');
140 $fulfilled = call_user_func($evaluation, $cfgValue);
142 if (null === $testMessage) {
143 $testMessage = sprintf('%s %s be %s in php.ini',
145 $optional ? 'should' : 'must',
146 $evaluation ? 'enabled' : 'disabled'
150 if (null === $helpHtml) {
151 $helpHtml = sprintf('Set <strong>%s</strong> to <strong>%s</strong> in php.ini<a href="#phpini">*</a>.',
153 $evaluation ? 'on' : 'off'
157 $fulfilled = $evaluation == $cfgValue;
160 parent
::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional);
165 * A RequirementCollection represents a set of Requirement instances.
167 * @author Tobias Schultze <http://tobion.de>
169 class RequirementCollection
implements IteratorAggregate
174 private $requirements = array();
177 * Gets the current RequirementCollection as an Iterator.
179 * @return Traversable A Traversable interface
181 public function getIterator()
183 return new ArrayIterator($this->requirements
);
187 * Adds a Requirement.
189 * @param Requirement $requirement A Requirement instance
191 public function add(Requirement
$requirement)
193 $this->requirements
[] = $requirement;
197 * Adds a mandatory requirement.
199 * @param bool $fulfilled Whether the requirement is fulfilled
200 * @param string $testMessage The message for testing the requirement
201 * @param string $helpHtml The help text formatted in HTML for resolving the problem
202 * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
204 public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null)
206 $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false));
210 * Adds an optional recommendation.
212 * @param bool $fulfilled Whether the recommendation is fulfilled
213 * @param string $testMessage The message for testing the recommendation
214 * @param string $helpHtml The help text formatted in HTML for resolving the problem
215 * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
217 public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null)
219 $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true));
223 * Adds a mandatory requirement in form of a php.ini configuration.
225 * @param string $cfgName The configuration name used for ini_get()
226 * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false,
227 * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
228 * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
229 * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
230 * Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
231 * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived)
232 * @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)
233 * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
235 public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null)
237 $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false));
241 * Adds an optional recommendation in form of a php.ini configuration.
243 * @param string $cfgName The configuration name used for ini_get()
244 * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false,
245 * or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
246 * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
247 * This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
248 * Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
249 * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived)
250 * @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)
251 * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
253 public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null)
255 $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true));
259 * Adds a requirement collection to the current set of requirements.
261 * @param RequirementCollection $collection A RequirementCollection instance
263 public function addCollection(RequirementCollection
$collection)
265 $this->requirements
= array_merge($this->requirements
, $collection->all());
269 * Returns both requirements and recommendations.
271 * @return Requirement[]
273 public function all()
275 return $this->requirements
;
279 * Returns all mandatory requirements.
281 * @return Requirement[]
283 public function getRequirements()
286 foreach ($this->requirements
as $req) {
287 if (!$req->isOptional()) {
296 * Returns the mandatory requirements that were not met.
298 * @return Requirement[]
300 public function getFailedRequirements()
303 foreach ($this->requirements
as $req) {
304 if (!$req->isFulfilled() && !$req->isOptional()) {
313 * Returns all optional recommendations.
315 * @return Requirement[]
317 public function getRecommendations()
320 foreach ($this->requirements
as $req) {
321 if ($req->isOptional()) {
330 * Returns the recommendations that were not met.
332 * @return Requirement[]
334 public function getFailedRecommendations()
337 foreach ($this->requirements
as $req) {
338 if (!$req->isFulfilled() && $req->isOptional()) {
347 * Returns whether a php.ini configuration is not correct.
349 * @return bool php.ini configuration problem?
351 public function hasPhpIniConfigIssue()
353 foreach ($this->requirements
as $req) {
354 if (!$req->isFulfilled() && $req instanceof PhpIniRequirement
) {
363 * Returns the PHP configuration file (php.ini) path.
365 * @return string|false php.ini file path
367 public function getPhpIniConfigPath()
369 return get_cfg_var('cfg_file_path');
374 * This class specifies all requirements and optional recommendations that
375 * are necessary to run the Symfony Standard Edition.
377 * @author Tobias Schultze <http://tobion.de>
378 * @author Fabien Potencier <fabien@symfony.com>
380 class SymfonyRequirements
extends RequirementCollection
382 const LEGACY_REQUIRED_PHP_VERSION
= '5.3.3';
383 const REQUIRED_PHP_VERSION
= '5.5.9';
386 * Constructor that initializes the requirements.
388 public function __construct()
390 /* mandatory requirements follow */
392 $installedPhpVersion = PHP_VERSION
;
393 $requiredPhpVersion = $this->getPhpRequiredVersion();
395 $this->addRecommendation(
397 'Vendors should be installed in order to check all requirements.',
398 'Run the <code>composer install</code> command.',
399 'Run the "composer install" command.'
402 if (false !== $requiredPhpVersion) {
403 $this->addRequirement(
404 version_compare($installedPhpVersion, $requiredPhpVersion, '>='),
405 sprintf('PHP version must be at least %s (%s installed)', $requiredPhpVersion, $installedPhpVersion),
406 sprintf('You are running PHP version "<strong>%s</strong>", but Symfony needs at least PHP "<strong>%s</strong>" to run.
407 Before using Symfony, upgrade your PHP installation, preferably to the latest version.',
408 $installedPhpVersion, $requiredPhpVersion),
409 sprintf('Install PHP %s or newer (installed version is %s)', $requiredPhpVersion, $installedPhpVersion)
413 $this->addRequirement(
414 version_compare($installedPhpVersion, '5.3.16', '!='),
415 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it',
416 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)'
419 $this->addRequirement(
420 is_dir(__DIR__
.'/../vendor/composer'),
421 'Vendor libraries must be installed',
422 'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. '.
423 'Then run "<strong>php composer.phar install</strong>" to install them.'
426 $cacheDir = is_dir(__DIR__
.'/../var/cache') ? __DIR__
.'/../var/cache' : __DIR__
.'/cache';
428 $this->addRequirement(
429 is_writable($cacheDir),
430 'app/cache/ or var/cache/ directory must be writable',
431 'Change the permissions of either "<strong>app/cache/</strong>" or "<strong>var/cache/</strong>" directory so that the web server can write into it.'
434 $logsDir = is_dir(__DIR__
.'/../var/logs') ? __DIR__
.'/../var/logs' : __DIR__
.'/logs';
436 $this->addRequirement(
437 is_writable($logsDir),
438 'app/logs/ or var/logs/ directory must be writable',
439 'Change the permissions of either "<strong>app/logs/</strong>" or "<strong>var/logs/</strong>" directory so that the web server can write into it.'
442 if (version_compare($installedPhpVersion, '7.0.0', '<')) {
443 $this->addPhpIniRequirement(
444 'date.timezone', true, false,
445 'date.timezone setting must be set',
446 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).'
450 if (false !== $requiredPhpVersion && version_compare($installedPhpVersion, $requiredPhpVersion, '>=')) {
451 $this->addRequirement(
452 in_array(@date_default_timezone_get(), DateTimeZone
::listIdentifiers(), true),
453 sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()),
454 '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>.'
458 $this->addRequirement(
459 function_exists('iconv'),
460 'iconv() must be available',
461 'Install and enable the <strong>iconv</strong> extension.'
464 $this->addRequirement(
465 function_exists('json_encode'),
466 'json_encode() must be available',
467 'Install and enable the <strong>JSON</strong> extension.'
470 $this->addRequirement(
471 function_exists('session_start'),
472 'session_start() must be available',
473 'Install and enable the <strong>session</strong> extension.'
476 $this->addRequirement(
477 function_exists('ctype_alpha'),
478 'ctype_alpha() must be available',
479 'Install and enable the <strong>ctype</strong> extension.'
482 $this->addRequirement(
483 function_exists('token_get_all'),
484 'token_get_all() must be available',
485 'Install and enable the <strong>Tokenizer</strong> extension.'
488 $this->addRequirement(
489 function_exists('simplexml_import_dom'),
490 'simplexml_import_dom() must be available',
491 'Install and enable the <strong>SimpleXML</strong> extension.'
494 if (function_exists('apc_store') && ini_get('apc.enabled')) {
495 if (version_compare($installedPhpVersion, '5.4.0', '>=')) {
496 $this->addRequirement(
497 version_compare(phpversion('apc'), '3.1.13', '>='),
498 'APC version must be at least 3.1.13 when using PHP 5.4',
499 'Upgrade your <strong>APC</strong> extension (3.1.13+).'
502 $this->addRequirement(
503 version_compare(phpversion('apc'), '3.0.17', '>='),
504 'APC version must be at least 3.0.17',
505 'Upgrade your <strong>APC</strong> extension (3.0.17+).'
510 $this->addPhpIniRequirement('detect_unicode', false);
512 if (extension_loaded('suhosin')) {
513 $this->addPhpIniRequirement(
514 'suhosin.executor.include.whitelist',
515 create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'),
517 'suhosin
.executor
.include.whitelist must be configured correctly in php
.ini
',
518 'Add
"<strong>phar</strong>" to
<strong
>suhosin
.executor
.include.whitelist
</strong
> in php
.ini
<a href
="#phpini">*</a
>.'
522 if (extension_loaded('xdebug
')) {
523 $this->addPhpIniRequirement(
524 'xdebug
.show_exception_trace
', false, true
527 $this->addPhpIniRequirement(
528 'xdebug
.scream
', false, true
531 $this->addPhpIniRecommendation(
532 'xdebug
.max_nesting_level
',
533 create_function('$cfgValue', 'return $cfgValue > 100;'),
535 'xdebug.max_nesting_level should be above 100 in php.ini',
536 'Set "<strong>xdebug.max_nesting_level</strong>" to e.g. "<strong>250</strong>" in php.ini<a href="#phpini">*</a> to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.'
540 $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION
: null;
542 $this->addRequirement(
543 null !== $pcreVersion,
544 'PCRE extension must be available',
545 'Install the <strong>PCRE</strong> extension (version 8.0+).'
548 if (extension_loaded('mbstring')) {
549 $this->addPhpIniRequirement(
550 'mbstring.func_overload',
551 create_function('$cfgValue', 'return (int) $cfgValue === 0;'),
553 'string functions should not be overloaded
',
554 'Set
"<strong>mbstring.func_overload</strong>" to
<strong
>0</strong
> in php
.ini
<a href
="#phpini">*</a
> to disable
function overloading by the mbstring extension
.'
558 /* optional recommendations follow */
560 if (file_exists(__DIR__.'/../vendor
/composer
')) {
561 require_once __DIR__.'/../vendor
/autoload
.php
';
564 $r = new ReflectionClass('Sensio\Bundle\DistributionBundle\SensioDistributionBundle
');
566 $contents = file_get_contents(dirname($r->getFileName()).'/Resources
/skeleton
/app
/SymfonyRequirements
.php
');
567 } catch (ReflectionException $e) {
570 $this->addRecommendation(
571 file_get_contents(__FILE__) === $contents,
572 'Requirements file should be up
-to
-date
',
573 'Your requirements file is outdated
. Run composer install
and re
-check your configuration
.'
577 $this->addRecommendation(
578 version_compare($installedPhpVersion, '5.3.4', '>='),
579 'You should
use at least PHP
5.3.4 due to PHP bug
#52083 in earlier versions',
580 '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.'
583 $this->addRecommendation(
584 version_compare($installedPhpVersion, '5.3.8', '>='),
585 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156',
586 'Install PHP 5.3.8 or newer if your project uses annotations.'
589 $this->addRecommendation(
590 version_compare($installedPhpVersion, '5.4.0', '!='),
591 'You should not use PHP 5.4.0 due to the PHP bug #61453',
592 '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.'
595 $this->addRecommendation(
596 version_compare($installedPhpVersion, '5.4.11', '>='),
597 'When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)',
598 'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.'
601 $this->addRecommendation(
602 (version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<'))
604 version_compare($installedPhpVersion, '5.4.8', '>='),
605 'You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909',
606 'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.'
609 if (null !== $pcreVersion) {
610 $this->addRecommendation(
612 sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion),
613 '<strong>PCRE 8.0+</strong> is preconfigured in PHP since 5.3.2 but you are using an outdated version of it. Symfony probably works anyway but it is recommended to upgrade your PCRE extension.'
617 $this->addRecommendation(
618 class_exists('DomDocument'),
619 'PHP-DOM and PHP-XML modules should be installed',
620 'Install and enable the <strong>PHP-DOM</strong> and the <strong>PHP-XML</strong> modules.'
623 $this->addRecommendation(
624 function_exists('mb_strlen'),
625 'mb_strlen() should be available',
626 'Install and enable the <strong>mbstring</strong> extension.'
629 $this->addRecommendation(
630 function_exists('utf8_decode'),
631 'utf8_decode() should be available',
632 'Install and enable the <strong>XML</strong> extension.'
635 $this->addRecommendation(
636 function_exists('filter_var'),
637 'filter_var() should be available',
638 'Install and enable the <strong>filter</strong> extension.'
641 if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
642 $this->addRecommendation(
643 function_exists('posix_isatty'),
644 'posix_isatty() should be available',
645 'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).'
649 $this->addRecommendation(
650 extension_loaded('intl'),
651 'intl extension should be available',
652 'Install and enable the <strong>intl</strong> extension (used for validators).'
655 if (extension_loaded('intl')) {
656 // in some WAMP server installations, new Collator() returns null
657 $this->addRecommendation(
658 null !== new Collator('fr_FR'),
659 'intl extension should be correctly configured',
660 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.'
663 // check for compatible ICU versions (only done when you have the intl extension)
664 if (defined('INTL_ICU_VERSION')) {
665 $version = INTL_ICU_VERSION
;
667 $reflector = new ReflectionExtension('intl');
671 $output = strip_tags(ob_get_clean());
673 preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
674 $version = $matches[1];
677 $this->addRecommendation(
678 version_compare($version, '4.0', '>='),
679 'intl ICU version should be at least 4+',
680 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).'
683 if (class_exists('Symfony\Component\Intl\Intl')) {
684 $this->addRecommendation(
685 \Symfony\Component\Intl\Intl
::getIcuDataVersion() <= \Symfony\Component\Intl\Intl
::getIcuVersion(),
686 sprintf('intl ICU version installed on your system is outdated (%s) and does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl
::getIcuVersion(), \Symfony\Component\Intl\Intl
::getIcuDataVersion()),
687 'To get the latest internationalization data upgrade the ICU system package and the intl PHP extension.'
689 if (\Symfony\Component\Intl\Intl
::getIcuDataVersion() <= \Symfony\Component\Intl\Intl
::getIcuVersion()) {
690 $this->addRecommendation(
691 \Symfony\Component\Intl\Intl
::getIcuDataVersion() === \Symfony\Component\Intl\Intl
::getIcuVersion(),
692 sprintf('intl ICU version installed on your system (%s) does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl
::getIcuVersion(), \Symfony\Component\Intl\Intl
::getIcuDataVersion()),
693 'To avoid internationalization data inconsistencies upgrade the symfony/intl component.'
698 $this->addPhpIniRecommendation(
700 create_function('$cfgValue', 'return (int) $cfgValue === 0;'),
702 'intl
.error_level should be
0 in php
.ini
',
703 'Set
"<strong>intl.error_level</strong>" to
"<strong>0</strong>" in php
.ini
<a href
="#phpini">*</a
> to inhibit the messages when an error occurs in ICU functions
.'
708 (extension_loaded('eaccelerator
') && ini_get('eaccelerator
.enable
'))
710 (extension_loaded('apc
') && ini_get('apc
.enabled
'))
712 (extension_loaded('Zend Optimizer+
') && ini_get('zend_optimizerplus
.enable
'))
714 (extension_loaded('Zend OPcache
') && ini_get('opcache
.enable
'))
716 (extension_loaded('xcache
') && ini_get('xcache
.cacher
'))
718 (extension_loaded('wincache
') && ini_get('wincache
.ocenabled
'))
721 $this->addRecommendation(
723 'a PHP accelerator should be installed
',
724 'Install
and/or enable a
<strong
>PHP accelerator
</strong
> (highly recommended
).'
727 if ('WIN
' === strtoupper(substr(PHP_OS, 0, 3))) {
728 $this->addRecommendation(
729 $this->getRealpathCacheSize() >= 5 * 1024 * 1024,
730 'realpath_cache_size should be at least
5M in php
.ini
',
731 'Setting
"<strong>realpath_cache_size</strong>" to e
.g
. "<strong>5242880</strong>" or "<strong>5M</strong>" in php
.ini
<a href
="#phpini">*</a
> may improve performance on Windows significantly in some cases
.'
735 $this->addPhpIniRecommendation('short_open_tag
', false);
737 $this->addPhpIniRecommendation('magic_quotes_gpc
', false, true);
739 $this->addPhpIniRecommendation('register_globals
', false, true);
741 $this->addPhpIniRecommendation('session
.auto_start
', false);
743 $this->addRecommendation(
745 'PDO should be installed
',
746 'Install
<strong
>PDO
</strong
> (mandatory
for Doctrine
).'
749 if (class_exists('PDO
')) {
750 $drivers = PDO::getAvailableDrivers();
751 $this->addRecommendation(
753 sprintf('PDO should have some drivers
installed (currently available
: %s
)', count($drivers) ? implode(', ', $drivers) : 'none
'),
754 'Install
<strong
>PDO drivers
</strong
> (mandatory
for Doctrine
).'
760 * Loads realpath_cache_size from php.ini and converts it to int.
762 * (e.g. 16k is converted to 16384 int)
766 protected function getRealpathCacheSize()
768 $size = ini_get('realpath_cache_size
');
771 if (!ctype_digit($size)) {
772 $unit = strtolower(substr($size, -1, 1));
773 $size = (int) substr($size, 0, -1);
777 return $size * 1024 * 1024 * 1024;
779 return $size * 1024 * 1024;
788 * Defines PHP required version from Symfony version.
790 * @return string|false The PHP required version or false if it could not be guessed
792 protected function getPhpRequiredVersion()
794 if (!file_exists($path = __DIR__.'/../composer
.lock
')) {
798 $composerLock = json_decode(file_get_contents($path), true);
799 foreach ($composerLock['packages
'] as $package) {
800 $name = $package['name
'];
801 if ('symfony
/symfony
' !== $name && 'symfony
/http
-kernel
' !== $name) {
805 return (int) $package['version
'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION;