Daniel@0: Daniel@0: * Daniel@0: * For the full copyright and license information, please view the LICENSE Daniel@0: * file that was distributed with this source code. Daniel@0: */ Daniel@0: Daniel@0: /* Daniel@0: * Users of PHP 5.2 should be able to run the requirements checks. Daniel@0: * This is why the file and all classes must be compatible with PHP 5.2+ Daniel@0: * (e.g. not using namespaces and closures). Daniel@0: * Daniel@0: * ************** CAUTION ************** Daniel@0: * Daniel@0: * DO NOT EDIT THIS FILE as it will be overridden by Composer as part of Daniel@0: * the installation/update process. The original file resides in the Daniel@0: * SensioDistributionBundle. Daniel@0: * Daniel@0: * ************** CAUTION ************** Daniel@0: */ Daniel@0: Daniel@0: /** Daniel@0: * Represents a single PHP requirement, e.g. an installed extension. Daniel@0: * It can be a mandatory requirement or an optional recommendation. Daniel@0: * There is a special subclass, named PhpIniRequirement, to check a php.ini configuration. Daniel@0: * Daniel@0: * @author Tobias Schultze Daniel@0: */ Daniel@0: class Requirement Daniel@0: { Daniel@0: private $fulfilled; Daniel@0: private $testMessage; Daniel@0: private $helpText; Daniel@0: private $helpHtml; Daniel@0: private $optional; Daniel@0: Daniel@0: /** Daniel@0: * Constructor that initializes the requirement. Daniel@0: * Daniel@0: * @param bool $fulfilled Whether the requirement is fulfilled Daniel@0: * @param string $testMessage The message for testing the requirement Daniel@0: * @param string $helpHtml The help text formatted in HTML for resolving the problem Daniel@0: * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) Daniel@0: * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement Daniel@0: */ Daniel@0: public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) Daniel@0: { Daniel@0: $this->fulfilled = (bool) $fulfilled; Daniel@0: $this->testMessage = (string) $testMessage; Daniel@0: $this->helpHtml = (string) $helpHtml; Daniel@0: $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; Daniel@0: $this->optional = (bool) $optional; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns whether the requirement is fulfilled. Daniel@0: * Daniel@0: * @return bool true if fulfilled, otherwise false Daniel@0: */ Daniel@0: public function isFulfilled() Daniel@0: { Daniel@0: return $this->fulfilled; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns the message for testing the requirement. Daniel@0: * Daniel@0: * @return string The test message Daniel@0: */ Daniel@0: public function getTestMessage() Daniel@0: { Daniel@0: return $this->testMessage; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns the help text for resolving the problem Daniel@0: * Daniel@0: * @return string The help text Daniel@0: */ Daniel@0: public function getHelpText() Daniel@0: { Daniel@0: return $this->helpText; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns the help text formatted in HTML. Daniel@0: * Daniel@0: * @return string The HTML help Daniel@0: */ Daniel@0: public function getHelpHtml() Daniel@0: { Daniel@0: return $this->helpHtml; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns whether this is only an optional recommendation and not a mandatory requirement. Daniel@0: * Daniel@0: * @return bool true if optional, false if mandatory Daniel@0: */ Daniel@0: public function isOptional() Daniel@0: { Daniel@0: return $this->optional; Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Represents a PHP requirement in form of a php.ini configuration. Daniel@0: * Daniel@0: * @author Tobias Schultze Daniel@0: */ Daniel@0: class PhpIniRequirement extends Requirement Daniel@0: { Daniel@0: /** Daniel@0: * Constructor that initializes the requirement. Daniel@0: * Daniel@0: * @param string $cfgName The configuration name used for ini_get() Daniel@0: * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, Daniel@0: or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement Daniel@0: * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. Daniel@0: This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. Daniel@0: Example: You require a config to be true but PHP later removes this config and defaults it to true internally. Daniel@0: * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) Daniel@0: * @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) Daniel@0: * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) Daniel@0: * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement Daniel@0: */ Daniel@0: public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) Daniel@0: { Daniel@0: $cfgValue = ini_get($cfgName); Daniel@0: Daniel@0: if (is_callable($evaluation)) { Daniel@0: if (null === $testMessage || null === $helpHtml) { Daniel@0: throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); Daniel@0: } Daniel@0: Daniel@0: $fulfilled = call_user_func($evaluation, $cfgValue); Daniel@0: } else { Daniel@0: if (null === $testMessage) { Daniel@0: $testMessage = sprintf('%s %s be %s in php.ini', Daniel@0: $cfgName, Daniel@0: $optional ? 'should' : 'must', Daniel@0: $evaluation ? 'enabled' : 'disabled' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: if (null === $helpHtml) { Daniel@0: $helpHtml = sprintf('Set %s to %s in php.ini*.', Daniel@0: $cfgName, Daniel@0: $evaluation ? 'on' : 'off' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: $fulfilled = $evaluation == $cfgValue; Daniel@0: } Daniel@0: Daniel@0: parent::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional); Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * A RequirementCollection represents a set of Requirement instances. Daniel@0: * Daniel@0: * @author Tobias Schultze Daniel@0: */ Daniel@0: class RequirementCollection implements IteratorAggregate Daniel@0: { Daniel@0: private $requirements = array(); Daniel@0: Daniel@0: /** Daniel@0: * Gets the current RequirementCollection as an Iterator. Daniel@0: * Daniel@0: * @return Traversable A Traversable interface Daniel@0: */ Daniel@0: public function getIterator() Daniel@0: { Daniel@0: return new ArrayIterator($this->requirements); Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Adds a Requirement. Daniel@0: * Daniel@0: * @param Requirement $requirement A Requirement instance Daniel@0: */ Daniel@0: public function add(Requirement $requirement) Daniel@0: { Daniel@0: $this->requirements[] = $requirement; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Adds a mandatory requirement. Daniel@0: * Daniel@0: * @param bool $fulfilled Whether the requirement is fulfilled Daniel@0: * @param string $testMessage The message for testing the requirement Daniel@0: * @param string $helpHtml The help text formatted in HTML for resolving the problem Daniel@0: * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) Daniel@0: */ Daniel@0: public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null) Daniel@0: { Daniel@0: $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false)); Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Adds an optional recommendation. Daniel@0: * Daniel@0: * @param bool $fulfilled Whether the recommendation is fulfilled Daniel@0: * @param string $testMessage The message for testing the recommendation Daniel@0: * @param string $helpHtml The help text formatted in HTML for resolving the problem Daniel@0: * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) Daniel@0: */ Daniel@0: public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null) Daniel@0: { Daniel@0: $this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true)); Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Adds a mandatory requirement in form of a php.ini configuration. Daniel@0: * Daniel@0: * @param string $cfgName The configuration name used for ini_get() Daniel@0: * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, Daniel@0: or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement Daniel@0: * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. Daniel@0: This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. Daniel@0: Example: You require a config to be true but PHP later removes this config and defaults it to true internally. Daniel@0: * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) Daniel@0: * @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) Daniel@0: * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) Daniel@0: */ Daniel@0: public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) Daniel@0: { Daniel@0: $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false)); Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Adds an optional recommendation in form of a php.ini configuration. Daniel@0: * Daniel@0: * @param string $cfgName The configuration name used for ini_get() Daniel@0: * @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false, Daniel@0: or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement Daniel@0: * @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. Daniel@0: This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. Daniel@0: Example: You require a config to be true but PHP later removes this config and defaults it to true internally. Daniel@0: * @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived) Daniel@0: * @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) Daniel@0: * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) Daniel@0: */ Daniel@0: public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null) Daniel@0: { Daniel@0: $this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true)); Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Adds a requirement collection to the current set of requirements. Daniel@0: * Daniel@0: * @param RequirementCollection $collection A RequirementCollection instance Daniel@0: */ Daniel@0: public function addCollection(RequirementCollection $collection) Daniel@0: { Daniel@0: $this->requirements = array_merge($this->requirements, $collection->all()); Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns both requirements and recommendations. Daniel@0: * Daniel@0: * @return array Array of Requirement instances Daniel@0: */ Daniel@0: public function all() Daniel@0: { Daniel@0: return $this->requirements; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns all mandatory requirements. Daniel@0: * Daniel@0: * @return array Array of Requirement instances Daniel@0: */ Daniel@0: public function getRequirements() Daniel@0: { Daniel@0: $array = array(); Daniel@0: foreach ($this->requirements as $req) { Daniel@0: if (!$req->isOptional()) { Daniel@0: $array[] = $req; Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: return $array; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns the mandatory requirements that were not met. Daniel@0: * Daniel@0: * @return array Array of Requirement instances Daniel@0: */ Daniel@0: public function getFailedRequirements() Daniel@0: { Daniel@0: $array = array(); Daniel@0: foreach ($this->requirements as $req) { Daniel@0: if (!$req->isFulfilled() && !$req->isOptional()) { Daniel@0: $array[] = $req; Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: return $array; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns all optional recommendations. Daniel@0: * Daniel@0: * @return array Array of Requirement instances Daniel@0: */ Daniel@0: public function getRecommendations() Daniel@0: { Daniel@0: $array = array(); Daniel@0: foreach ($this->requirements as $req) { Daniel@0: if ($req->isOptional()) { Daniel@0: $array[] = $req; Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: return $array; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns the recommendations that were not met. Daniel@0: * Daniel@0: * @return array Array of Requirement instances Daniel@0: */ Daniel@0: public function getFailedRecommendations() Daniel@0: { Daniel@0: $array = array(); Daniel@0: foreach ($this->requirements as $req) { Daniel@0: if (!$req->isFulfilled() && $req->isOptional()) { Daniel@0: $array[] = $req; Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: return $array; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns whether a php.ini configuration is not correct. Daniel@0: * Daniel@0: * @return bool php.ini configuration problem? Daniel@0: */ Daniel@0: public function hasPhpIniConfigIssue() Daniel@0: { Daniel@0: foreach ($this->requirements as $req) { Daniel@0: if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) { Daniel@0: return true; Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: return false; Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Returns the PHP configuration file (php.ini) path. Daniel@0: * Daniel@0: * @return string|false php.ini file path Daniel@0: */ Daniel@0: public function getPhpIniConfigPath() Daniel@0: { Daniel@0: return get_cfg_var('cfg_file_path'); Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * This class specifies all requirements and optional recommendations that Daniel@0: * are necessary to run the Symfony Standard Edition. Daniel@0: * Daniel@0: * @author Tobias Schultze Daniel@0: * @author Fabien Potencier Daniel@0: */ Daniel@0: class SymfonyRequirements extends RequirementCollection Daniel@0: { Daniel@0: const REQUIRED_PHP_VERSION = '5.3.3'; Daniel@0: Daniel@0: /** Daniel@0: * Constructor that initializes the requirements. Daniel@0: */ Daniel@0: public function __construct() Daniel@0: { Daniel@0: /* mandatory requirements follow */ Daniel@0: Daniel@0: $installedPhpVersion = phpversion(); Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), Daniel@0: sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), Daniel@0: sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. Daniel@0: Before using Symfony, upgrade your PHP installation, preferably to the latest version.', Daniel@0: $installedPhpVersion, self::REQUIRED_PHP_VERSION), Daniel@0: sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion) Daniel@0: ); Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: version_compare($installedPhpVersion, '5.3.16', '!='), Daniel@0: 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', Daniel@0: 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)' Daniel@0: ); Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: is_dir(__DIR__.'/../vendor/composer'), Daniel@0: 'Vendor libraries must be installed', Daniel@0: 'Vendor libraries are missing. Install composer following instructions from http://getcomposer.org/. '. Daniel@0: 'Then run "php composer.phar install" to install them.' Daniel@0: ); Daniel@0: Daniel@0: $cacheDir = is_dir(__DIR__.'/../var/cache') ? __DIR__.'/../var/cache' : __DIR__.'/cache'; Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: is_writable($cacheDir), Daniel@0: 'app/cache/ or var/cache/ directory must be writable', Daniel@0: 'Change the permissions of either "app/cache/" or "var/cache/" directory so that the web server can write into it.' Daniel@0: ); Daniel@0: Daniel@0: $logsDir = is_dir(__DIR__.'/../var/logs') ? __DIR__.'/../var/logs' : __DIR__.'/logs'; Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: is_writable($logsDir), Daniel@0: 'app/logs/ or var/logs/ directory must be writable', Daniel@0: 'Change the permissions of either "app/logs/" or "var/logs/" directory so that the web server can write into it.' Daniel@0: ); Daniel@0: Daniel@0: $this->addPhpIniRequirement( Daniel@0: 'date.timezone', true, false, Daniel@0: 'date.timezone setting must be set', Daniel@0: 'Set the "date.timezone" setting in php.ini* (like Europe/Paris).' Daniel@0: ); Daniel@0: Daniel@0: if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { Daniel@0: $timezones = array(); Daniel@0: foreach (DateTimeZone::listAbbreviations() as $abbreviations) { Daniel@0: foreach ($abbreviations as $abbreviation) { Daniel@0: $timezones[$abbreviation['timezone_id']] = true; Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: isset($timezones[@date_default_timezone_get()]), Daniel@0: sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()), Daniel@0: 'Your default timezone is not supported by PHP. Check for typos in your php.ini file and have a look at the list of deprecated timezones at http://php.net/manual/en/timezones.others.php.' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: function_exists('json_encode'), Daniel@0: 'json_encode() must be available', Daniel@0: 'Install and enable the JSON extension.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: function_exists('session_start'), Daniel@0: 'session_start() must be available', Daniel@0: 'Install and enable the session extension.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: function_exists('ctype_alpha'), Daniel@0: 'ctype_alpha() must be available', Daniel@0: 'Install and enable the ctype extension.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: function_exists('token_get_all'), Daniel@0: 'token_get_all() must be available', Daniel@0: 'Install and enable the Tokenizer extension.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: function_exists('simplexml_import_dom'), Daniel@0: 'simplexml_import_dom() must be available', Daniel@0: 'Install and enable the SimpleXML extension.' Daniel@0: ); Daniel@0: Daniel@0: if (function_exists('apc_store') && ini_get('apc.enabled')) { Daniel@0: if (version_compare($installedPhpVersion, '5.4.0', '>=')) { Daniel@0: $this->addRequirement( Daniel@0: version_compare(phpversion('apc'), '3.1.13', '>='), Daniel@0: 'APC version must be at least 3.1.13 when using PHP 5.4', Daniel@0: 'Upgrade your APC extension (3.1.13+).' Daniel@0: ); Daniel@0: } else { Daniel@0: $this->addRequirement( Daniel@0: version_compare(phpversion('apc'), '3.0.17', '>='), Daniel@0: 'APC version must be at least 3.0.17', Daniel@0: 'Upgrade your APC extension (3.0.17+).' Daniel@0: ); Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: $this->addPhpIniRequirement('detect_unicode', false); Daniel@0: Daniel@0: if (extension_loaded('suhosin')) { Daniel@0: $this->addPhpIniRequirement( Daniel@0: 'suhosin.executor.include.whitelist', Daniel@0: create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), Daniel@0: false, Daniel@0: 'suhosin.executor.include.whitelist must be configured correctly in php.ini', Daniel@0: 'Add "phar" to suhosin.executor.include.whitelist in php.ini*.' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: if (extension_loaded('xdebug')) { Daniel@0: $this->addPhpIniRequirement( Daniel@0: 'xdebug.show_exception_trace', false, true Daniel@0: ); Daniel@0: Daniel@0: $this->addPhpIniRequirement( Daniel@0: 'xdebug.scream', false, true Daniel@0: ); Daniel@0: Daniel@0: $this->addPhpIniRecommendation( Daniel@0: 'xdebug.max_nesting_level', Daniel@0: create_function('$cfgValue', 'return $cfgValue > 100;'), Daniel@0: true, Daniel@0: 'xdebug.max_nesting_level should be above 100 in php.ini', Daniel@0: 'Set "xdebug.max_nesting_level" to e.g. "250" in php.ini* to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; Daniel@0: Daniel@0: $this->addRequirement( Daniel@0: null !== $pcreVersion, Daniel@0: 'PCRE extension must be available', Daniel@0: 'Install the PCRE extension (version 8.0+).' Daniel@0: ); Daniel@0: Daniel@0: if (extension_loaded('mbstring')) { Daniel@0: $this->addPhpIniRequirement( Daniel@0: 'mbstring.func_overload', Daniel@0: create_function('$cfgValue', 'return (int) $cfgValue === 0;'), Daniel@0: true, Daniel@0: 'string functions should not be overloaded', Daniel@0: 'Set "mbstring.func_overload" to 0 in php.ini* to disable function overloading by the mbstring extension.' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: /* optional recommendations follow */ Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: file_get_contents(__FILE__) === file_get_contents(__DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'), Daniel@0: 'Requirements file should be up-to-date', Daniel@0: 'Your requirements file is outdated. Run composer install and re-check your configuration.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: version_compare($installedPhpVersion, '5.3.4', '>='), Daniel@0: 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', Daniel@0: '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.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: version_compare($installedPhpVersion, '5.3.8', '>='), Daniel@0: 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', Daniel@0: 'Install PHP 5.3.8 or newer if your project uses annotations.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: version_compare($installedPhpVersion, '5.4.0', '!='), Daniel@0: 'You should not use PHP 5.4.0 due to the PHP bug #61453', Daniel@0: '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.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: version_compare($installedPhpVersion, '5.4.11', '>='), Daniel@0: '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)', Daniel@0: 'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: (version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<')) Daniel@0: || Daniel@0: version_compare($installedPhpVersion, '5.4.8', '>='), Daniel@0: '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', Daniel@0: 'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.' Daniel@0: ); Daniel@0: Daniel@0: if (null !== $pcreVersion) { Daniel@0: $this->addRecommendation( Daniel@0: $pcreVersion >= 8.0, Daniel@0: sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion), Daniel@0: 'PCRE 8.0+ 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.' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: class_exists('DomDocument'), Daniel@0: 'PHP-DOM and PHP-XML modules should be installed', Daniel@0: 'Install and enable the PHP-DOM and the PHP-XML modules.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: function_exists('mb_strlen'), Daniel@0: 'mb_strlen() should be available', Daniel@0: 'Install and enable the mbstring extension.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: function_exists('iconv'), Daniel@0: 'iconv() should be available', Daniel@0: 'Install and enable the iconv extension.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: function_exists('utf8_decode'), Daniel@0: 'utf8_decode() should be available', Daniel@0: 'Install and enable the XML extension.' Daniel@0: ); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: function_exists('filter_var'), Daniel@0: 'filter_var() should be available', Daniel@0: 'Install and enable the filter extension.' Daniel@0: ); Daniel@0: Daniel@0: if (!defined('PHP_WINDOWS_VERSION_BUILD')) { Daniel@0: $this->addRecommendation( Daniel@0: function_exists('posix_isatty'), Daniel@0: 'posix_isatty() should be available', Daniel@0: 'Install and enable the php_posix extension (used to colorize the CLI output).' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: class_exists('Locale'), Daniel@0: 'intl extension should be available', Daniel@0: 'Install and enable the intl extension (used for validators).' Daniel@0: ); Daniel@0: Daniel@0: if (class_exists('Collator')) { Daniel@0: $this->addRecommendation( Daniel@0: null !== new Collator('fr_FR'), Daniel@0: 'intl extension should be correctly configured', Daniel@0: 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: if (class_exists('Locale')) { Daniel@0: if (defined('INTL_ICU_VERSION')) { Daniel@0: $version = INTL_ICU_VERSION; Daniel@0: } else { Daniel@0: $reflector = new ReflectionExtension('intl'); Daniel@0: Daniel@0: ob_start(); Daniel@0: $reflector->info(); Daniel@0: $output = strip_tags(ob_get_clean()); Daniel@0: Daniel@0: preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches); Daniel@0: $version = $matches[1]; Daniel@0: } Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: version_compare($version, '4.0', '>='), Daniel@0: 'intl ICU version should be at least 4+', Daniel@0: 'Upgrade your intl extension with a newer ICU version (4+).' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: $accelerator = Daniel@0: (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) Daniel@0: || Daniel@0: (extension_loaded('apc') && ini_get('apc.enabled')) Daniel@0: || Daniel@0: (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable')) Daniel@0: || Daniel@0: (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) Daniel@0: || Daniel@0: (extension_loaded('xcache') && ini_get('xcache.cacher')) Daniel@0: || Daniel@0: (extension_loaded('wincache') && ini_get('wincache.ocenabled')) Daniel@0: ; Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: $accelerator, Daniel@0: 'a PHP accelerator should be installed', Daniel@0: 'Install and/or enable a PHP accelerator (highly recommended).' Daniel@0: ); Daniel@0: Daniel@0: if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { Daniel@0: $this->addRecommendation( Daniel@0: $this->getRealpathCacheSize() > 1000, Daniel@0: 'realpath_cache_size should be above 1024 in php.ini', Daniel@0: 'Set "realpath_cache_size" to e.g. "1024" in php.ini* to improve performance on windows.' Daniel@0: ); Daniel@0: } Daniel@0: Daniel@0: $this->addPhpIniRecommendation('short_open_tag', false); Daniel@0: Daniel@0: $this->addPhpIniRecommendation('magic_quotes_gpc', false, true); Daniel@0: Daniel@0: $this->addPhpIniRecommendation('register_globals', false, true); Daniel@0: Daniel@0: $this->addPhpIniRecommendation('session.auto_start', false); Daniel@0: Daniel@0: $this->addRecommendation( Daniel@0: class_exists('PDO'), Daniel@0: 'PDO should be installed', Daniel@0: 'Install PDO (mandatory for Doctrine).' Daniel@0: ); Daniel@0: Daniel@0: if (class_exists('PDO')) { Daniel@0: $drivers = PDO::getAvailableDrivers(); Daniel@0: $this->addRecommendation( Daniel@0: count($drivers) > 0, Daniel@0: sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), Daniel@0: 'Install PDO drivers (mandatory for Doctrine).' Daniel@0: ); Daniel@0: } Daniel@0: } Daniel@0: Daniel@0: /** Daniel@0: * Loads realpath_cache_size from php.ini and converts it to int. Daniel@0: * Daniel@0: * (e.g. 16k is converted to 16384 int) Daniel@0: * Daniel@0: * @return int Daniel@0: */ Daniel@0: protected function getRealpathCacheSize() Daniel@0: { Daniel@0: $size = ini_get('realpath_cache_size'); Daniel@0: $size = trim($size); Daniel@0: $unit = strtolower(substr($size, -1, 1)); Daniel@0: switch ($unit) { Daniel@0: case 'g': Daniel@0: return $size * 1024 * 1024 * 1024; Daniel@0: case 'm': Daniel@0: return $size * 1024 * 1024; Daniel@0: case 'k': Daniel@0: return $size * 1024; Daniel@0: default: Daniel@0: return (int) $size; Daniel@0: } Daniel@0: } Daniel@0: }