Example #1
0
 /**
  * Prints phpinfo block for the extension
  * @return void
  */
 public function info()
 {
     if ($this->reflectionSource) {
         $this->reflectionSource->info();
     } else {
         parent::info();
     }
 }
 protected function getIcuVersion()
 {
     if (defined('INTL_ICU_VERSION')) {
         $version = INTL_ICU_VERSION;
     } else {
         $reflector = new \ReflectionExtension('intl');
         ob_start();
         $reflector->info();
         $output = strip_tags(ob_get_clean());
         preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
         $version = $matches[1];
     }
     return $version;
 }
 protected function getIntlExtensionIcuVersion()
 {
     if (isset(self::$icuVersion)) {
         return self::$icuVersion;
     }
     if (!$this->isIntlExtensionLoaded()) {
         throw new \RuntimeException('The intl extension is not available');
     }
     if (defined('INTL_ICU_VERSION')) {
         return INTL_ICU_VERSION;
     }
     $reflector = new \ReflectionExtension('intl');
     ob_start();
     $reflector->info();
     $output = ob_get_clean();
     preg_match('/^ICU version => (.*)$/m', $output, $matches);
     self::$icuVersion = $matches[1];
     return self::$icuVersion;
 }
 protected function getIcuVersion()
 {
     static $icuVersion = null;
     if (defined('INTL_ICU_VERSION')) {
         return INTL_ICU_VERSION;
     }
     if ($icuVersion === null) {
         $icuVersion = 0;
         $ext = new ReflectionExtension('intl');
         ob_start();
         $ext->info();
         $info = ob_get_contents();
         if (preg_match('/ICU Version => (.*)/i', $info, $match)) {
             $icuVersion = $match[1];
         }
         ob_end_clean();
     }
     return $icuVersion;
 }
 public function __construct($locale = 'en')
 {
     $this->setName('Locales');
     $this->addRequirement(class_exists('Locale'), 'intl extension should be available', 'Install and enable the <strong>intl</strong> extension (used for validators).');
     if (class_exists('Collator')) {
         $this->addRecommendation(null !== new \Collator('fr'), 'intl extension should be correctly configured', 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.');
     }
     if (class_exists('Locale')) {
         if (defined('INTL_ICU_VERSION')) {
             $version = INTL_ICU_VERSION;
         } else {
             $reflector = new \ReflectionExtension('intl');
             ob_start();
             $reflector->info();
             $output = strip_tags(ob_get_clean());
             preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
             $version = $matches[1];
         }
         $this->addRecommendation(version_compare($version, '4.0', '>='), 'intl ICU version should be at least 4+', 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).');
     }
 }
Example #6
0
 protected function initialize()
 {
     parent::initialize();
     $versionParser = new VersionParser();
     // Add each of the override versions as options.
     // Later we might even replace the extensions instead.
     foreach ($this->overrides as $override) {
         // Check that it's a platform package.
         if (!preg_match(self::PLATFORM_PACKAGE_REGEX, $override['name'])) {
             throw new \InvalidArgumentException('Invalid platform package name in config.platform: ' . $override['name']);
         }
         $version = $versionParser->normalize($override['version']);
         $package = new CompletePackage($override['name'], $version, $override['version']);
         $package->setDescription('Package overridden via config.platform');
         $package->setExtra(array('config.platform' => true));
         parent::addPackage($package);
     }
     $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
     $version = $versionParser->normalize($prettyVersion);
     $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
     $composerPluginApi->setDescription('The Composer Plugin API');
     $this->addPackage($composerPluginApi);
     try {
         $prettyVersion = PHP_VERSION;
         $version = $versionParser->normalize($prettyVersion);
     } catch (\UnexpectedValueException $e) {
         $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION);
         $version = $versionParser->normalize($prettyVersion);
     }
     $php = new CompletePackage('php', $version, $prettyVersion);
     $php->setDescription('The PHP interpreter');
     $this->addPackage($php);
     if (PHP_INT_SIZE === 8) {
         $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
         $php64->setDescription('The PHP interpreter, 64bit');
         $this->addPackage($php64);
     }
     $loadedExtensions = get_loaded_extensions();
     // Extensions scanning
     foreach ($loadedExtensions as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $reflExt = new \ReflectionExtension($name);
         try {
             $prettyVersion = $reflExt->getVersion();
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $version = $versionParser->normalize($prettyVersion);
         }
         $packageName = $this->buildPackageName($name);
         $ext = new CompletePackage($packageName, $version, $prettyVersion);
         $ext->setDescription('The ' . $name . ' PHP extension');
         $this->addPackage($ext);
     }
     // Another quick loop, just for possible libraries
     // Doing it this way to know that functions or constants exist before
     // relying on them.
     foreach ($loadedExtensions as $name) {
         $prettyVersion = null;
         $description = 'The ' . $name . ' PHP library';
         switch ($name) {
             case 'curl':
                 $curlVersion = curl_version();
                 $prettyVersion = $curlVersion['version'];
                 break;
             case 'iconv':
                 $prettyVersion = ICONV_VERSION;
                 break;
             case 'intl':
                 $name = 'ICU';
                 if (defined('INTL_ICU_VERSION')) {
                     $prettyVersion = INTL_ICU_VERSION;
                 } else {
                     $reflector = new \ReflectionExtension('intl');
                     ob_start();
                     $reflector->info();
                     $output = ob_get_clean();
                     preg_match('/^ICU version => (.*)$/m', $output, $matches);
                     $prettyVersion = $matches[1];
                 }
                 break;
             case 'libxml':
                 $prettyVersion = LIBXML_DOTTED_VERSION;
                 break;
             case 'openssl':
                 $prettyVersion = preg_replace_callback('{^(?:OpenSSL\\s*)?([0-9.]+)([a-z]*).*}', function ($match) {
                     if (empty($match[2])) {
                         return $match[1];
                     }
                     // OpenSSL versions add another letter when they reach Z.
                     // e.g. OpenSSL 0.9.8zh 3 Dec 2015
                     if (!preg_match('{^z*[a-z]$}', $match[2])) {
                         // 0.9.8abc is garbage
                         return 0;
                     }
                     $len = strlen($match[2]);
                     $patchVersion = ($len - 1) * 26;
                     // All Z
                     $patchVersion += ord($match[2][$len - 1]) - 96;
                     return $match[1] . '.' . $patchVersion;
                 }, OPENSSL_VERSION_TEXT);
                 $description = OPENSSL_VERSION_TEXT;
                 break;
             case 'pcre':
                 $prettyVersion = preg_replace('{^(\\S+).*}', '$1', PCRE_VERSION);
                 break;
             case 'uuid':
                 $prettyVersion = phpversion('uuid');
                 break;
             case 'xsl':
                 $prettyVersion = LIBXSLT_DOTTED_VERSION;
                 break;
             default:
                 // None handled extensions have no special cases, skip
                 continue 2;
         }
         try {
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             continue;
         }
         $lib = new CompletePackage('lib-' . $name, $version, $prettyVersion);
         $lib->setDescription($description);
         $this->addPackage($lib);
     }
     if (defined('HHVM_VERSION')) {
         try {
             $prettyVersion = HHVM_VERSION;
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', HHVM_VERSION);
             $version = $versionParser->normalize($prettyVersion);
         }
         $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
         $hhvm->setDescription('The HHVM Runtime (64bit)');
         $this->addPackage($hhvm);
     }
 }
 /**
  * Constructor that initializes the requirements.
  */
 public function __construct()
 {
     /* mandatory requirements follow */
     $installedPhpVersion = phpversion();
     $this->addRequirement(version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), sprintf('You are running PHP version "<strong>%s</strong>", but Symfony needs at least PHP "<strong>%s</strong>" to run.
             Before using Symfony, upgrade your PHP installation, preferably to the latest version.', $installedPhpVersion, self::REQUIRED_PHP_VERSION), sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion));
     $this->addRequirement(is_dir(__DIR__ . '/../vendor/composer'), 'Vendor libraries must be installed', 'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. ' . 'Then run "<strong>php composer.phar install</strong>" to install them.');
     $this->addRequirement(file_get_contents(__FILE__) == file_get_contents(__DIR__ . '/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'), 'Outdated requirements file', 'Your requirements file is outdated. Run composer install and re-check your configuration.');
     $baseDir = basename(__DIR__);
     $this->addRequirement(is_writable(__DIR__ . '/cache'), "{$baseDir}/cache/ directory must be writable", "Change the permissions of the \"<strong>{$baseDir}/cache/</strong>\" directory so that the web server can write into it.");
     $this->addRequirement(is_writable(__DIR__ . '/logs'), "{$baseDir}/logs/ directory must be writable", "Change the permissions of the \"<strong>{$baseDir}/logs/</strong>\" directory so that the web server can write into it.");
     $this->addPhpIniRequirement('date.timezone', true, false, 'date.timezone setting must be set', 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).');
     if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) {
         $this->addRequirement(in_array(date_default_timezone_get(), DateTimeZone::listIdentifiers()), sprintf('Default timezone "%s" is not supported by your installation of PHP', date_default_timezone_get()), 'Fix your <strong>php.ini</strong> file (check for typos and have a look at the list of deprecated timezones http://php.net/manual/en/timezones.others.php).');
     }
     $this->addRequirement(function_exists('json_encode'), 'json_encode() must be available', 'Install and enable the <strong>JSON</strong> extension.');
     $this->addRequirement(function_exists('session_start'), 'session_start() must be available', 'Install and enable the <strong>session</strong> extension.');
     $this->addRequirement(function_exists('ctype_alpha'), 'ctype_alpha() must be available', 'Install and enable the <strong>ctype</strong> extension.');
     $this->addRequirement(function_exists('token_get_all'), 'token_get_all() must be available', 'Install and enable the <strong>Tokenizer</strong> extension.');
     $this->addRequirement(function_exists('simplexml_import_dom'), 'simplexml_import_dom() must be available', 'Install and enable the <strong>SimpleXML</strong> extension.');
     $this->addRequirement(!(function_exists('apc_store') && ini_get('apc.enabled')) || version_compare(phpversion('apc'), '3.0.17', '>='), 'APC version must be at least 3.0.17', 'Upgrade your <strong>APC</strong> extension (3.0.17+)');
     $this->addPhpIniRequirement('detect_unicode', false);
     $this->addPhpIniRequirement('suhosin.executor.include.whitelist', create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), true, 'suhosin.executor.include.whitelist must be configured correctly in php.ini', 'Add "<strong>phar</strong>" to <strong>suhosin.executor.include.whitelist</strong> in php.ini<a href="#phpini">*</a>.');
     $pcreVersion = defined('PCRE_VERSION') ? (double) PCRE_VERSION : null;
     $this->addRequirement(null !== $pcreVersion && $pcreVersion > 8.0, sprintf('PCRE extension must be available and at least 8.0 (%s installed)', $pcreVersion ? $pcreVersion : 'not'), 'Upgrade your <strong>PCRE</strong> extension (8.0+)');
     /* optional recommendations follow */
     $this->addRecommendation(version_compare($installedPhpVersion, '5.3.4', '>='), sprintf('Your project might not work properly ("Notice: Trying to get property of non-object") due to the PHP bug #52083 before PHP 5.3.4 (%s installed)', $installedPhpVersion), 'Install PHP 5.3.4 or newer');
     $this->addRecommendation(version_compare($installedPhpVersion, '5.3.8', '>='), sprintf('Annotations might not work properly due to the PHP bug #55156 before PHP 5.3.8 (%s installed)', $installedPhpVersion), 'Install PHP 5.3.8 or newer if your project uses annotations');
     $this->addRecommendation(class_exists('DomDocument'), 'PHP-XML module should be installed', 'Install and enable the <strong>PHP-XML</strong> module.');
     $this->addRecommendation(function_exists('mb_strlen'), 'mb_strlen() should be available', 'Install and enable the <strong>mbstring</strong> extension.');
     $this->addRecommendation(function_exists('iconv'), 'iconv() should be available', 'Install and enable the <strong>iconv</strong> extension.');
     $this->addRecommendation(function_exists('utf8_decode'), 'utf8_decode() should be available', 'Install and enable the <strong>XML</strong> extension.');
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $this->addRecommendation(function_exists('posix_isatty'), 'posix_isatty() should be available', 'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).');
     }
     $this->addRecommendation(class_exists('Locale'), 'intl extension should be available', 'Install and enable the <strong>intl</strong> extension (used for validators).');
     if (class_exists('Locale')) {
         if (defined('INTL_ICU_VERSION')) {
             $version = INTL_ICU_VERSION;
         } else {
             $reflector = new ReflectionExtension('intl');
             ob_start();
             $reflector->info();
             $output = strip_tags(ob_get_clean());
             preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
             $version = $matches[1];
         }
         $this->addRecommendation(version_compare($version, '4.0', '>='), 'intl ICU version should be at least 4+', 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).');
     }
     $accelerator = function_exists('apc_store') && ini_get('apc.enabled') || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set');
     $this->addRecommendation($accelerator, 'a PHP accelerator should be installed', 'Install and enable a <strong>PHP accelerator</strong> like APC (highly recommended).');
     $this->addPhpIniRecommendation('short_open_tag', false);
     $this->addPhpIniRecommendation('magic_quotes_gpc', false, true);
     $this->addPhpIniRecommendation('register_globals', false, true);
     $this->addPhpIniRecommendation('session.auto_start', false);
     $this->addRecommendation(class_exists('PDO'), 'PDO should be installed', 'Install <strong>PDO</strong> (mandatory for Doctrine).');
     if (class_exists('PDO')) {
         $drivers = PDO::getAvailableDrivers();
         $this->addRecommendation(count($drivers), sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), 'Install <strong>PDO drivers</strong> (mandatory for Doctrine).');
     }
 }
 /**
  * Constructor that initializes the requirements.
  */
 public function __construct()
 {
     /* mandatory requirements follow */
     $installedPhpVersion = phpversion();
     $this->addRequirement(version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), sprintf('You are running PHP version "<strong>%s</strong>", but Symfony needs at least PHP "<strong>%s</strong>" to run.
             Before using Symfony, upgrade your PHP installation, preferably to the latest version.', $installedPhpVersion, self::REQUIRED_PHP_VERSION), sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion));
     $this->addRequirement(version_compare($installedPhpVersion, '5.3.16', '!='), 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)');
     $this->addRequirement(is_dir(__DIR__ . '/../vendor/composer'), 'Vendor libraries must be installed', 'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. ' . 'Then run "<strong>php composer.phar install</strong>" to install them.');
     $baseDir = basename(__DIR__);
     $this->addRequirement(is_writable(__DIR__ . '/cache'), "{$baseDir}/cache/ directory must be writable", "Change the permissions of the \"<strong>{$baseDir}/cache/</strong>\" directory so that the web server can write into it.");
     $this->addRequirement(is_writable(__DIR__ . '/logs'), "{$baseDir}/logs/ directory must be writable", "Change the permissions of the \"<strong>{$baseDir}/logs/</strong>\" directory so that the web server can write into it.");
     $this->addPhpIniRequirement('date.timezone', true, false, 'date.timezone setting must be set', 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).');
     if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) {
         $timezones = array();
         foreach (DateTimeZone::listAbbreviations() as $abbreviations) {
             foreach ($abbreviations as $abbreviation) {
                 $timezones[$abbreviation['timezone_id']] = true;
             }
         }
         $this->addRequirement(isset($timezones[date_default_timezone_get()]), sprintf('Configured default timezone "%s" must be supported by your installation of PHP', date_default_timezone_get()), '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>.');
     }
     $this->addRequirement(function_exists('json_encode'), 'json_encode() must be available', 'Install and enable the <strong>JSON</strong> extension.');
     $this->addRequirement(function_exists('session_start'), 'session_start() must be available', 'Install and enable the <strong>session</strong> extension.');
     $this->addRequirement(function_exists('ctype_alpha'), 'ctype_alpha() must be available', 'Install and enable the <strong>ctype</strong> extension.');
     $this->addRequirement(function_exists('token_get_all'), 'token_get_all() must be available', 'Install and enable the <strong>Tokenizer</strong> extension.');
     $this->addRequirement(function_exists('simplexml_import_dom'), 'simplexml_import_dom() must be available', 'Install and enable the <strong>SimpleXML</strong> extension.');
     if (function_exists('apc_store') && ini_get('apc.enabled')) {
         $this->addRequirement(version_compare(phpversion('apc'), '3.0.17', '>='), 'APC version must be at least 3.0.17', 'Upgrade your <strong>APC</strong> extension (3.0.17+).');
     }
     $this->addPhpIniRequirement('detect_unicode', false);
     if (extension_loaded('suhosin')) {
         $this->addPhpIniRequirement('suhosin.executor.include.whitelist', create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), false, 'suhosin.executor.include.whitelist must be configured correctly in php.ini', 'Add "<strong>phar</strong>" to <strong>suhosin.executor.include.whitelist</strong> in php.ini<a href="#phpini">*</a>.');
     }
     if (extension_loaded('xdebug')) {
         $this->addPhpIniRequirement('xdebug.show_exception_trace', false, true);
         $this->addPhpIniRequirement('xdebug.scream', false, true);
         $this->addPhpIniRecommendation('xdebug.max_nesting_level', create_function('$cfgValue', 'return $cfgValue > 100;'), true, 'xdebug.max_nesting_level should be above 100 in php.ini', '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.');
     }
     $pcreVersion = defined('PCRE_VERSION') ? (double) PCRE_VERSION : null;
     $this->addRequirement(null !== $pcreVersion, 'PCRE extension must be available', 'Install the <strong>PCRE</strong> extension (version 8.0+).');
     /* optional recommendations follow */
     $this->addRecommendation(file_get_contents(__FILE__) === file_get_contents(__DIR__ . '/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'), 'Requirements file should be up-to-date', 'Your requirements file is outdated. Run composer install and re-check your configuration.');
     $this->addRecommendation(version_compare($installedPhpVersion, '5.3.4', '>='), 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', '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.');
     $this->addRecommendation(version_compare($installedPhpVersion, '5.3.8', '>='), 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', 'Install PHP 5.3.8 or newer if your project uses annotations.');
     $this->addRecommendation(version_compare($installedPhpVersion, '5.4.0', '!='), 'You should not use PHP 5.4.0 due to the PHP bug #61453', '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.');
     if (null !== $pcreVersion) {
         $this->addRecommendation($pcreVersion >= 8.0, sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion), '<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.');
     }
     $this->addRecommendation(class_exists('DomDocument'), 'PHP-XML module should be installed', 'Install and enable the <strong>PHP-XML</strong> module.');
     $this->addRecommendation(function_exists('mb_strlen'), 'mb_strlen() should be available', 'Install and enable the <strong>mbstring</strong> extension.');
     $this->addRecommendation(function_exists('iconv'), 'iconv() should be available', 'Install and enable the <strong>iconv</strong> extension.');
     $this->addRecommendation(function_exists('utf8_decode'), 'utf8_decode() should be available', 'Install and enable the <strong>XML</strong> extension.');
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $this->addRecommendation(function_exists('posix_isatty'), 'posix_isatty() should be available', 'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).');
     }
     $this->addRecommendation(class_exists('Locale'), 'intl extension should be available', 'Install and enable the <strong>intl</strong> extension (used for validators).');
     if (class_exists('Collator')) {
         $this->addRecommendation(null !== new Collator('fr_FR'), 'intl extension should be correctly configured', 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.');
     }
     if (class_exists('Locale')) {
         if (defined('INTL_ICU_VERSION')) {
             $version = INTL_ICU_VERSION;
         } else {
             $reflector = new ReflectionExtension('intl');
             ob_start();
             $reflector->info();
             $output = strip_tags(ob_get_clean());
             preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
             $version = $matches[1];
         }
         $this->addRecommendation(version_compare($version, '4.0', '>='), 'intl ICU version should be at least 4+', 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).');
     }
     $accelerator = function_exists('apc_store') && ini_get('apc.enabled') || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set');
     $this->addRecommendation($accelerator, 'a PHP accelerator should be installed', 'Install and enable a <strong>PHP accelerator</strong> like APC (highly recommended).');
     $this->addPhpIniRecommendation('short_open_tag', false);
     $this->addPhpIniRecommendation('magic_quotes_gpc', false, true);
     $this->addPhpIniRecommendation('register_globals', false, true);
     $this->addPhpIniRecommendation('session.auto_start', false);
     $this->addRecommendation(class_exists('PDO'), 'PDO should be installed', 'Install <strong>PDO</strong> (mandatory for Doctrine).');
     if (class_exists('PDO')) {
         $drivers = PDO::getAvailableDrivers();
         $this->addRecommendation(count($drivers), sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), 'Install <strong>PDO drivers</strong> (mandatory for Doctrine).');
     }
 }
 protected function initialize()
 {
     $loadedExtensions = get_loaded_extensions();
     $packages = array();
     // Extensions scanning
     foreach ($loadedExtensions as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $ext = new \ReflectionExtension($name);
         try {
             $prettyVersion = $ext->getVersion();
             $prettyVersion = $this->normalizeVersion($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $prettyVersion = $this->normalizeVersion($prettyVersion);
         }
         $packages[$this->buildPackageName($name)] = $prettyVersion;
     }
     foreach ($loadedExtensions as $name) {
         $prettyVersion = null;
         switch ($name) {
             case 'curl':
                 $curlVersion = curl_version();
                 $prettyVersion = $curlVersion['version'];
                 break;
             case 'iconv':
                 $prettyVersion = ICONV_VERSION;
                 break;
             case 'intl':
                 $name = 'ICU';
                 if (defined('INTL_ICU_VERSION')) {
                     $prettyVersion = INTL_ICU_VERSION;
                 } else {
                     $reflector = new \ReflectionExtension('intl');
                     ob_start();
                     $reflector->info();
                     $output = ob_get_clean();
                     preg_match('/^ICU version => (.*)$/m', $output, $matches);
                     $prettyVersion = $matches[1];
                 }
                 break;
             case 'libxml':
                 $prettyVersion = LIBXML_DOTTED_VERSION;
                 break;
             case 'openssl':
                 $prettyVersion = preg_replace_callback('{^(?:OpenSSL\\s*)?([0-9.]+)([a-z]?).*}', function ($match) {
                     return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96));
                 }, OPENSSL_VERSION_TEXT);
                 break;
             case 'pcre':
                 $prettyVersion = preg_replace('{^(\\S+).*}', '$1', PCRE_VERSION);
                 break;
             case 'uuid':
                 $prettyVersion = phpversion('uuid');
                 break;
             case 'xsl':
                 $prettyVersion = LIBXSLT_DOTTED_VERSION;
                 break;
             default:
                 // None handled extensions have no special cases, skip
                 continue 2;
         }
         try {
             $prettyVersion = $this->normalizeVersion($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             continue;
         }
         $packages[$this->buildPackageName($name)] = $prettyVersion;
     }
     return $packages;
 }
 /**
  * Constructor that initializes the requirements.
  */
 public function __construct()
 {
     /* mandatory requirements follow */
     $installedPhpVersion = phpversion();
     $this->addRequirement(version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), sprintf('You are running PHP version "<strong>%s</strong>", but Symfony needs at least PHP "<strong>%s</strong>" to run.
             Before using Symfony, upgrade your PHP installation, preferably to the latest version.', $installedPhpVersion, self::REQUIRED_PHP_VERSION), sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion));
     $this->addRequirement(is_dir(__DIR__ . '/../vendor/symfony'), 'Vendor libraries must be installed', 'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. ' . 'Then run "<strong>php composer.phar install</strong>" to install them.');
     $this->addRequirement(is_writable(__DIR__ . '/../app/cache'), 'app/cache/ directory must be writable', 'Change the permissions of the "<strong>app/cache/</strong>" directory so that the web server can write into it.');
     $this->addRequirement(is_writable(__DIR__ . '/../app/logs'), 'app/logs/ directory must be writable', 'Change the permissions of the "<strong>app/logs/</strong>" directory so that the web server can write into it.');
     $this->addPhpIniRequirement('date.timezone', true, false, 'date.timezone setting must be set', 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).');
     $this->addRequirement(function_exists('json_encode'), 'json_encode() must be available', 'Install and enable the <strong>JSON</strong> extension.');
     $this->addRequirement(function_exists('session_start'), 'session_start() must be available', 'Install and enable the <strong>session</strong> extension.');
     $this->addRequirement(function_exists('ctype_alpha'), 'ctype_alpha() must be available', 'Install and enable the <strong>ctype</strong> extension.');
     $this->addRequirement(function_exists('token_get_all'), 'token_get_all() must be available', 'Install and enable the <strong>Tokenizer</strong> extension.');
     $this->addRequirement(function_exists('simplexml_import_dom'), 'simplexml_import_dom() must be available', 'Install and enable the <strong>SimpleXML</strong> extension.');
     $this->addRequirement(!(function_exists('apc_store') && ini_get('apc.enabled')) || version_compare(phpversion('apc'), '3.0.17', '>='), 'APC version must be at least 3.0.17', 'Upgrade your <strong>APC</strong> extension (3.0.17+)');
     $this->addPhpIniRequirement('detect_unicode', false);
     $this->addPhpIniRequirement('suhosin.executor.include.whitelist', create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), true, 'suhosin.executor.include.whitelist must be configured correctly in php.ini', 'Add "<strong>phar</strong>" to <strong>suhosin.executor.include.whitelist</strong> in php.ini<a href="#phpini">*</a>.');
     $pcreVersion = defined('PCRE_VERSION') ? (double) PCRE_VERSION : null;
     $this->addRequirement(null !== $pcreVersion && $pcreVersion > 8.0, sprintf('PCRE extension must be available and at least 8.0 (%s installed)', $pcreVersion ? $pcreVersion : 'not'), 'Upgrade your <strong>PCRE</strong> extension (8.0+)');
     /* optional recommendations follow */
     $this->addRecommendation(class_exists('DomDocument'), 'PHP-XML module should be installed', 'Install and enable the <strong>PHP-XML</strong> module.');
     $this->addRecommendation(function_exists('mb_strlen'), 'mb_strlen() should be available', 'Install and enable the <strong>mbstring</strong> extension.');
     $this->addRecommendation(function_exists('iconv'), 'iconv() should be available', 'Install and enable the <strong>iconv</strong> extension.');
     $this->addRecommendation(function_exists('utf8_decode'), 'utf8_decode() should be available', 'Install and enable the <strong>XML</strong> extension.');
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $this->addRecommendation(function_exists('posix_isatty'), 'posix_isatty() should be available', 'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).');
     }
     $this->addRecommendation(class_exists('Locale'), 'intl extension should be available', 'Install and enable the <strong>intl</strong> extension (used for validators).');
     if (class_exists('Locale')) {
         if (defined('INTL_ICU_VERSION')) {
             $version = INTL_ICU_VERSION;
         } else {
             $reflector = new ReflectionExtension('intl');
             ob_start();
             $reflector->info();
             $output = strip_tags(ob_get_clean());
             preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
             $version = $matches[1];
         }
         $this->addRecommendation(version_compare($version, '4.0', '>='), 'intl ICU version should be at least 4+', 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).');
     }
     $accelerator = function_exists('apc_store') && ini_get('apc.enabled') || function_exists('eaccelerator_put') && ini_get('eaccelerator.enable') || function_exists('xcache_set');
     $this->addRecommendation($accelerator, 'a PHP accelerator should be installed', 'Install and enable a <strong>PHP accelerator</strong> like APC (highly recommended).');
     $this->addPhpIniRecommendation('short_open_tag', false);
     $this->addPhpIniRecommendation('magic_quotes_gpc', false, true);
     $this->addPhpIniRecommendation('register_globals', false, true);
     $this->addPhpIniRecommendation('session.auto_start', false);
     $this->addRecommendation(class_exists('PDO'), 'PDO should be installed', 'Install <strong>PDO</strong> (mandatory for Doctrine).');
     if (class_exists('PDO')) {
         $drivers = PDO::getAvailableDrivers();
         $this->addRecommendation(count($drivers), sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), 'Install <strong>PDO drivers</strong> (mandatory for Doctrine).');
     }
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function checkOptionalSettings()
 {
     $phpSupportData = array('5.3' => array('security' => '2013-07-11', 'eos' => '2014-08-14'), '5.4' => array('security' => '2014-09-14', 'eos' => '2015-09-14'), '5.5' => array('security' => '2015-07-10', 'eos' => '2016-07-10'), '5.6' => array('security' => '2016-08-28', 'eos' => '2017-08-28'));
     $messages = array();
     // Check the PHP version's support status
     $activePhpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;
     // Do we have the PHP version's data?
     if (isset($phpSupportData[$activePhpVersion])) {
         // First check if the version has reached end of support
         $today = new \DateTime();
         $phpEndOfSupport = new \DateTime($phpSupportData[$activePhpVersion]['eos']);
         if ($phpNotSupported = $today > $phpEndOfSupport) {
             $messages[] = 'mautic.install.php.version.not.supported';
         }
         // If the version is still supported, check if it has reached security support only
         $phpSecurityOnlyDate = new \DateTime($phpSupportData[$activePhpVersion]['security']);
         if (!$phpNotSupported && $today > $phpSecurityOnlyDate) {
             $messages[] = 'mautic.install.php.version.has.only.security.support';
         }
     }
     if (version_compare(PHP_VERSION, '5.3.8', '<')) {
         $messages[] = 'mautic.install.php.version.annotations';
     }
     if (version_compare(PHP_VERSION, '5.4.0', '=')) {
         $messages[] = 'mautic.install.php.version.dump';
     }
     if (PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 18 || PHP_MINOR_VERSION == 4 && PHP_RELEASE_VERSION < 8) {
         $messages[] = 'mautic.install.php.version.pretty.error';
     }
     $pcreVersion = defined('PCRE_VERSION') ? (double) PCRE_VERSION : null;
     if (!is_null($pcreVersion)) {
         if (version_compare($pcreVersion, '8.0', '<')) {
             $messages[] = 'mautic.install.pcre.version';
         }
     }
     if (extension_loaded('xdebug')) {
         $cfgValue = ini_get('xdebug.max_nesting_level');
         if (!call_user_func(create_function('$cfgValue', 'return $cfgValue > 100;'), $cfgValue)) {
             $messages[] = 'mautic.install.xdebug.nesting';
         }
     }
     // We set a default timezone in the app bootstrap, but advise the user if their PHP config is missing it
     if (!ini_get('date.timezone')) {
         $messages[] = 'mautic.install.date.timezone.not.set';
     }
     if (!class_exists('\\DomDocument')) {
         $messages[] = 'mautic.install.module.phpxml';
     }
     if (!function_exists('mb_strlen')) {
         $messages[] = 'mautic.install.function.mbstring';
     }
     if (!function_exists('iconv')) {
         $messages[] = 'mautic.install.function.iconv';
     }
     if (!function_exists('utf8_decode')) {
         $messages[] = 'mautic.install.function.xml';
     }
     if (function_exists('imap_open')) {
         $messages[] = 'mautic.install.extension.imap';
     }
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         if (!function_exists('posix_isatty')) {
             $messages[] = 'mautic.install.function.posix';
         }
     }
     if (!class_exists('\\Locale')) {
         $messages[] = 'mautic.install.module.intl';
     }
     if (class_exists('\\Collator')) {
         try {
             if (is_null(new \Collator('fr_FR'))) {
                 $messages[] = 'mautic.install.intl.config';
             }
         } catch (\Exception $exception) {
             $messages[] = 'mautic.install.intl.config';
         }
     }
     if (class_exists('\\Locale')) {
         if (defined('INTL_ICU_VERSION')) {
             $version = INTL_ICU_VERSION;
         } else {
             try {
                 $reflector = new \ReflectionExtension('intl');
                 ob_start();
                 $reflector->info();
                 $output = strip_tags(ob_get_clean());
                 preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
                 $version = $matches[1];
             } catch (\ReflectionException $exception) {
                 $messages[] = 'mautic.install.module.intl';
                 // Fake the version here for the next check
                 $version = '4.0';
             }
         }
         if (version_compare($version, '4.0', '<')) {
             $messages[] = 'mautic.install.intl.icu.version';
         }
     }
     $accelerator = extension_loaded('eaccelerator') && ini_get('eaccelerator.enable') || extension_loaded('apc') && ini_get('apc.enabled') || extension_loaded('Zend OPcache') && ini_get('opcache.enable') || extension_loaded('xcache') && ini_get('xcache.cacher') || extension_loaded('wincache') && ini_get('wincache.ocenabled');
     if (!$accelerator) {
         $messages[] = 'mautic.install.accelerator';
     }
     return $messages;
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 public function checkOptionalSettings()
 {
     $messages = [];
     $pcreVersion = defined('PCRE_VERSION') ? (double) PCRE_VERSION : null;
     if (!is_null($pcreVersion)) {
         if (version_compare($pcreVersion, '8.0', '<')) {
             $messages[] = 'mautic.install.pcre.version';
         }
     }
     if (extension_loaded('xdebug')) {
         $cfgValue = ini_get('xdebug.max_nesting_level');
         if (!call_user_func(create_function('$cfgValue', 'return $cfgValue > 100;'), $cfgValue)) {
             $messages[] = 'mautic.install.xdebug.nesting';
         }
     }
     if (!extension_loaded('zip')) {
         $messages[] = 'mautic.install.extension.zip';
     }
     // We set a default timezone in the app bootstrap, but advise the user if their PHP config is missing it
     if (!ini_get('date.timezone')) {
         $messages[] = 'mautic.install.date.timezone.not.set';
     }
     if (!class_exists('\\DomDocument')) {
         $messages[] = 'mautic.install.module.phpxml';
     }
     if (!function_exists('iconv')) {
         $messages[] = 'mautic.install.function.iconv';
     }
     if (!function_exists('utf8_decode')) {
         $messages[] = 'mautic.install.function.xml';
     }
     if (!function_exists('imap_open')) {
         $messages[] = 'mautic.install.extension.imap';
     }
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         if (!function_exists('posix_isatty')) {
             $messages[] = 'mautic.install.function.posix';
         }
     }
     $memoryLimit = $this->toBytes(ini_get('memory_limit'));
     $suggestedLimit = 128 * 1024 * 1024;
     if ($memoryLimit < $suggestedLimit) {
         $messages[] = 'mautic.install.memory.limit';
     }
     if (!class_exists('\\Locale')) {
         $messages[] = 'mautic.install.module.intl';
     }
     if (class_exists('\\Collator')) {
         try {
             if (is_null(new \Collator('fr_FR'))) {
                 $messages[] = 'mautic.install.intl.config';
             }
         } catch (\Exception $exception) {
             $messages[] = 'mautic.install.intl.config';
         }
     }
     if (class_exists('\\Locale')) {
         if (defined('INTL_ICU_VERSION')) {
             $version = INTL_ICU_VERSION;
         } else {
             try {
                 $reflector = new \ReflectionExtension('intl');
                 ob_start();
                 $reflector->info();
                 $output = strip_tags(ob_get_clean());
                 preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
                 $version = $matches[1];
             } catch (\ReflectionException $exception) {
                 $messages[] = 'mautic.install.module.intl';
                 // Fake the version here for the next check
                 $version = '4.0';
             }
         }
         if (version_compare($version, '4.0', '<')) {
             $messages[] = 'mautic.install.intl.icu.version';
         }
     }
     return $messages;
 }
<?php

$obj = new ReflectionExtension('reflection');
ob_start();
$testa = $obj->info();
$testb = ob_get_clean();
var_dump($testa);
var_dump(strlen($testb) > 24);
?>
==DONE==
Example #14
0
File: TH.php Project: cargomedia/cm
 /**
  * @return float
  * @throws CM_Exception
  */
 public static function getVersionICU()
 {
     $ext = new ReflectionExtension('intl');
     ob_start();
     $ext->info();
     $info = ob_get_clean();
     if (!preg_match('#^ICU version => ([\\d\\.]+)$#um', $info, $matches)) {
         throw new CM_Exception('Cannot detect ICU version', null, ['info' => $info]);
     }
     return (double) $matches[1];
 }
 protected function initialize()
 {
     parent::initialize();
     $versionParser = new VersionParser();
     try {
         $prettyVersion = PHP_VERSION;
         $version = $versionParser->normalize($prettyVersion);
     } catch (\UnexpectedValueException $e) {
         $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION);
         $version = $versionParser->normalize($prettyVersion);
     }
     $php = new CompletePackage('php', $version, $prettyVersion);
     $php->setDescription('The PHP interpreter');
     parent::addPackage($php);
     if (PHP_INT_SIZE === 8) {
         $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
         $php64->setDescription('The PHP interpreter (64bit)');
         parent::addPackage($php64);
     }
     $loadedExtensions = get_loaded_extensions();
     // Extensions scanning
     foreach ($loadedExtensions as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $reflExt = new \ReflectionExtension($name);
         try {
             $prettyVersion = $reflExt->getVersion();
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $version = $versionParser->normalize($prettyVersion);
         }
         $ext = new CompletePackage('ext-' . $name, $version, $prettyVersion);
         $ext->setDescription('The ' . $name . ' PHP extension');
         parent::addPackage($ext);
     }
     // Another quick loop, just for possible libraries
     // Doing it this way to know that functions or constants exist before
     // relying on them.
     foreach ($loadedExtensions as $name) {
         $prettyVersion = null;
         switch ($name) {
             case 'curl':
                 $curlVersion = curl_version();
                 $prettyVersion = $curlVersion['version'];
                 break;
             case 'iconv':
                 $prettyVersion = ICONV_VERSION;
                 break;
             case 'intl':
                 $name = 'ICU';
                 if (defined('INTL_ICU_VERSION')) {
                     $prettyVersion = INTL_ICU_VERSION;
                 } else {
                     $reflector = new \ReflectionExtension('intl');
                     ob_start();
                     $reflector->info();
                     $output = ob_get_clean();
                     preg_match('/^ICU version => (.*)$/m', $output, $matches);
                     $prettyVersion = $matches[1];
                 }
                 break;
             case 'libxml':
                 $prettyVersion = LIBXML_DOTTED_VERSION;
                 break;
             case 'openssl':
                 $prettyVersion = preg_replace_callback('{^(?:OpenSSL\\s*)?([0-9.]+)([a-z]?).*}', function ($match) {
                     return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96));
                 }, OPENSSL_VERSION_TEXT);
                 break;
             case 'pcre':
                 $prettyVersion = preg_replace('{^(\\S+).*}', '$1', PCRE_VERSION);
                 break;
             case 'uuid':
                 $prettyVersion = phpversion('uuid');
                 break;
             case 'xsl':
                 $prettyVersion = LIBXSLT_DOTTED_VERSION;
                 break;
             default:
                 // None handled extensions have no special cases, skip
                 continue 2;
         }
         try {
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             continue;
         }
         $lib = new CompletePackage('lib-' . $name, $version, $prettyVersion);
         $lib->setDescription('The ' . $name . ' PHP library');
         parent::addPackage($lib);
     }
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function checkOptionalSettings()
 {
     $messages = array();
     if (version_compare(PHP_VERSION, '5.3.8', '<')) {
         $messages[] = 'mautic.install.php.version.annotations';
     }
     if (version_compare(PHP_VERSION, '5.4.0', '=')) {
         $messages[] = 'mautic.install.php.version.dump';
     }
     if (PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 18 || PHP_MINOR_VERSION == 4 && PHP_RELEASE_VERSION < 8) {
         $messages[] = 'mautic.install.php.version.pretty.error';
     }
     $pcreVersion = defined('PCRE_VERSION') ? (double) PCRE_VERSION : null;
     if (!is_null($pcreVersion)) {
         if (version_compare($pcreVersion, '8.0', '<')) {
             $messages[] = 'mautic.install.pcre.version';
         }
     }
     if (extension_loaded('xdebug')) {
         $cfgValue = ini_get('xdebug.max_nesting_level');
         if (!call_user_func(create_function('$cfgValue', 'return $cfgValue > 100;'), $cfgValue)) {
             $messages[] = 'mautic.install.xdebug.nesting';
         }
     }
     // We set a default timezone in the app bootstrap, but advise the user if their PHP config is missing it
     if (!ini_get('date.timezone')) {
         $messages[] = 'mautic.install.date.timezone.not.set';
     }
     if (!class_exists('\\DomDocument')) {
         $messages[] = 'mautic.install.module.phpxml';
     }
     if (!extension_loaded('mcrypt')) {
         $messages[] = 'mautic.install.extension.mcrypt';
     }
     if (!function_exists('mb_strlen')) {
         $messages[] = 'mautic.install.function.mbstring';
     }
     if (!function_exists('iconv')) {
         $messages[] = 'mautic.install.function.iconv';
     }
     if (!function_exists('utf8_decode')) {
         $messages[] = 'mautic.install.function.xml';
     }
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         if (!function_exists('posix_isatty')) {
             $messages[] = 'mautic.install.function.posix';
         }
     }
     if (!class_exists('\\Locale')) {
         $messages[] = 'mautic.install.module.intl';
     }
     if (class_exists('\\Collator')) {
         try {
             if (is_null(new \Collator('fr_FR'))) {
                 $messages[] = 'mautic.install.intl.config';
             }
         } catch (\Exception $exception) {
             $messages[] = 'mautic.install.intl.config';
         }
     }
     if (class_exists('\\Locale')) {
         if (defined('INTL_ICU_VERSION')) {
             $version = INTL_ICU_VERSION;
         } else {
             try {
                 $reflector = new \ReflectionExtension('intl');
                 ob_start();
                 $reflector->info();
                 $output = strip_tags(ob_get_clean());
                 preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
                 $version = $matches[1];
             } catch (\ReflectionException $exception) {
                 $messages[] = 'mautic.install.module.intl';
                 // Fake the version here for the next check
                 $version = '4.0';
             }
         }
         if (version_compare($version, '4.0', '<')) {
             $messages[] = 'mautic.install.intl.icu.version';
         }
     }
     $accelerator = extension_loaded('eaccelerator') && ini_get('eaccelerator.enable') || extension_loaded('apc') && ini_get('apc.enabled') || extension_loaded('Zend OPcache') && ini_get('opcache.enable') || extension_loaded('xcache') && ini_get('xcache.cacher') || extension_loaded('wincache') && ini_get('wincache.ocenabled');
     if (!$accelerator) {
         $messages[] = 'mautic.install.accelerator';
     }
     return $messages;
 }
Example #17
0
 protected function initialize()
 {
     parent::initialize();
     $versionParser = new VersionParser();
     $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
     $version = $versionParser->normalize($prettyVersion);
     $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
     $composerPluginApi->setDescription('The Composer Plugin API');
     parent::addPackage($composerPluginApi);
     try {
         $prettyVersion = PHP_VERSION;
         $version = $versionParser->normalize($prettyVersion);
     } catch (\UnexpectedValueException $e) {
         $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION);
         $version = $versionParser->normalize($prettyVersion);
     }
     $php = new CompletePackage('php', $version, $prettyVersion);
     $php->setDescription('The PHP interpreter');
     parent::addPackage($php);
     if (PHP_INT_SIZE === 8) {
         $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
         $php64->setDescription('The PHP interpreter (64bit)');
         parent::addPackage($php64);
     }
     $loadedExtensions = get_loaded_extensions();
     foreach ($loadedExtensions as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $reflExt = new \ReflectionExtension($name);
         try {
             $prettyVersion = $reflExt->getVersion();
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $version = $versionParser->normalize($prettyVersion);
         }
         $packageName = $this->buildPackageName($name);
         $ext = new CompletePackage($packageName, $version, $prettyVersion);
         $ext->setDescription('The ' . $name . ' PHP extension');
         parent::addPackage($ext);
     }
     foreach ($loadedExtensions as $name) {
         $prettyVersion = null;
         switch ($name) {
             case 'curl':
                 $curlVersion = curl_version();
                 $prettyVersion = $curlVersion['version'];
                 break;
             case 'iconv':
                 $prettyVersion = ICONV_VERSION;
                 break;
             case 'intl':
                 $name = 'ICU';
                 if (defined('INTL_ICU_VERSION')) {
                     $prettyVersion = INTL_ICU_VERSION;
                 } else {
                     $reflector = new \ReflectionExtension('intl');
                     ob_start();
                     $reflector->info();
                     $output = ob_get_clean();
                     preg_match('/^ICU version => (.*)$/m', $output, $matches);
                     $prettyVersion = $matches[1];
                 }
                 break;
             case 'libxml':
                 $prettyVersion = LIBXML_DOTTED_VERSION;
                 break;
             case 'openssl':
                 $prettyVersion = preg_replace_callback('{^(?:OpenSSL\\s*)?([0-9.]+)([a-z]?).*}', function ($match) {
                     return $match[1] . (empty($match[2]) ? '' : '.' . (ord($match[2]) - 96));
                 }, OPENSSL_VERSION_TEXT);
                 break;
             case 'pcre':
                 $prettyVersion = preg_replace('{^(\\S+).*}', '$1', PCRE_VERSION);
                 break;
             case 'uuid':
                 $prettyVersion = phpversion('uuid');
                 break;
             case 'xsl':
                 $prettyVersion = LIBXSLT_DOTTED_VERSION;
                 break;
             default:
                 continue 2;
         }
         try {
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             continue;
         }
         $lib = new CompletePackage('lib-' . $name, $version, $prettyVersion);
         $lib->setDescription('The ' . $name . ' PHP library');
         parent::addPackage($lib);
     }
     if (defined('HHVM_VERSION')) {
         try {
             $prettyVersion = HHVM_VERSION;
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', HHVM_VERSION);
             $version = $versionParser->normalize($prettyVersion);
         }
         $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
         $hhvm->setDescription('The HHVM Runtime (64bit)');
         parent::addPackage($hhvm);
     }
 }
Example #18
0
<?php

$r = new ReflectionExtension("reflection");
$r->info();
date_default_timezone_set('Europe/Berlin');
$r = new ReflectionExtension("date");
$r->info();
echo "\nDone!\n";
Example #19
0
if (!function_exists('utf8_decode')) {
    $minorProblems[] = 'Install and enable the <strong>XML</strong> extension.';
}
if (PHP_OS != 'WINNT' && !function_exists('posix_isatty')) {
    $minorProblems[] = 'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).';
}
if (!class_exists('Locale')) {
    $minorProblems[] = 'Install and enable the <strong>intl</strong> extension.';
} else {
    $version = '';
    if (defined('INTL_ICU_VERSION')) {
        $version = INTL_ICU_VERSION;
    } else {
        $reflector = new \ReflectionExtension('intl');
        ob_start();
        $reflector->info();
        $output = strip_tags(ob_get_clean());
        preg_match('/^ICU version (.*)$/m', $output, $matches);
        $version = $matches[1];
    }
    if (!version_compare($version, '4.0', '>=')) {
        $minorProblems[] = 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).';
    }
}
if (!class_exists('SQLite3') && !in_array('sqlite', PDO::getAvailableDrivers())) {
    $majorProblems[] = 'Install and enable the <strong>SQLite3</strong> or <strong>PDO_SQLite</strong> extension.';
}
if (!function_exists('json_encode')) {
    $majorProblems[] = 'Install and enable the <strong>json</strong> extension.';
}
if (!function_exists('session_start')) {
 /**
  * Dump information about mysqli.
  * 
  * This is used by the view in case no statistics were collected to
  * ease the debugging
  * 
  * @return string
  */
 public function getMysqlInfo()
 {
     if (!extension_loaded("mysqli")) {
         return "The mysqli extension is not available at all.";
     }
     ob_start();
     $re = new \ReflectionExtension("mysqli");
     $re->info();
     $info = ob_get_contents();
     ob_end_clean();
     return str_replace('<h2><a name="module_mysqli">mysqli</a></h2>', '', $info);
 }
 /**
  * Constructor that initializes the requirements.
  */
 public function __construct()
 {
     /* mandatory requirements follow */
     $installedPhpVersion = phpversion();
     $requiredPhpVersion = $this->getPhpRequiredVersion();
     $this->addRecommendation($requiredPhpVersion, 'Vendors should be installed in order to check all requirements.', 'Run the <code>composer install</code> command.', 'Run the "composer install" command.');
     if (false !== $requiredPhpVersion) {
         $this->addRequirement(version_compare($installedPhpVersion, $requiredPhpVersion, '>='), sprintf('PHP version must be at least %s (%s installed)', $requiredPhpVersion, $installedPhpVersion), sprintf('You are running PHP version "<strong>%s</strong>", but Symfony needs at least PHP "<strong>%s</strong>" to run.
             Before using Symfony, upgrade your PHP installation, preferably to the latest version.', $installedPhpVersion, $requiredPhpVersion), sprintf('Install PHP %s or newer (installed version is %s)', $requiredPhpVersion, $installedPhpVersion));
     }
     $this->addRequirement(version_compare($installedPhpVersion, '5.3.16', '!='), 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', 'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)');
     $this->addRequirement(is_dir(__DIR__ . '/../vendor/composer'), 'Vendor libraries must be installed', 'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. ' . 'Then run "<strong>php composer.phar install</strong>" to install them.');
     $cacheDir = is_dir(__DIR__ . '/../var/cache') ? __DIR__ . '/../var/cache' : __DIR__ . '/cache';
     $this->addRequirement(is_writable($cacheDir), 'app/cache/ or var/cache/ directory must be writable', 'Change the permissions of either "<strong>app/cache/</strong>" or  "<strong>var/cache/</strong>" directory so that the web server can write into it.');
     $logsDir = is_dir(__DIR__ . '/../var/logs') ? __DIR__ . '/../var/logs' : __DIR__ . '/logs';
     $this->addRequirement(is_writable($logsDir), 'app/logs/ or var/logs/ directory must be writable', 'Change the permissions of either "<strong>app/logs/</strong>" or  "<strong>var/logs/</strong>" directory so that the web server can write into it.');
     $this->addPhpIniRequirement('date.timezone', true, false, 'date.timezone setting must be set', 'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).');
     if (false !== $requiredPhpVersion && version_compare($installedPhpVersion, $requiredPhpVersion, '>=')) {
         $timezones = array();
         foreach (DateTimeZone::listAbbreviations() as $abbreviations) {
             foreach ($abbreviations as $abbreviation) {
                 $timezones[$abbreviation['timezone_id']] = true;
             }
         }
         $this->addRequirement(isset($timezones[@date_default_timezone_get()]), sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()), '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>.');
     }
     $this->addRequirement(function_exists('iconv'), 'iconv() must be available', 'Install and enable the <strong>iconv</strong> extension.');
     $this->addRequirement(function_exists('json_encode'), 'json_encode() must be available', 'Install and enable the <strong>JSON</strong> extension.');
     $this->addRequirement(function_exists('session_start'), 'session_start() must be available', 'Install and enable the <strong>session</strong> extension.');
     $this->addRequirement(function_exists('ctype_alpha'), 'ctype_alpha() must be available', 'Install and enable the <strong>ctype</strong> extension.');
     $this->addRequirement(function_exists('token_get_all'), 'token_get_all() must be available', 'Install and enable the <strong>Tokenizer</strong> extension.');
     $this->addRequirement(function_exists('simplexml_import_dom'), 'simplexml_import_dom() must be available', 'Install and enable the <strong>SimpleXML</strong> extension.');
     if (function_exists('apc_store') && ini_get('apc.enabled')) {
         if (version_compare($installedPhpVersion, '5.4.0', '>=')) {
             $this->addRequirement(version_compare(phpversion('apc'), '3.1.13', '>='), 'APC version must be at least 3.1.13 when using PHP 5.4', 'Upgrade your <strong>APC</strong> extension (3.1.13+).');
         } else {
             $this->addRequirement(version_compare(phpversion('apc'), '3.0.17', '>='), 'APC version must be at least 3.0.17', 'Upgrade your <strong>APC</strong> extension (3.0.17+).');
         }
     }
     $this->addPhpIniRequirement('detect_unicode', false);
     if (extension_loaded('suhosin')) {
         $this->addPhpIniRequirement('suhosin.executor.include.whitelist', create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'), false, 'suhosin.executor.include.whitelist must be configured correctly in php.ini', 'Add "<strong>phar</strong>" to <strong>suhosin.executor.include.whitelist</strong> in php.ini<a href="#phpini">*</a>.');
     }
     if (extension_loaded('xdebug')) {
         $this->addPhpIniRequirement('xdebug.show_exception_trace', false, true);
         $this->addPhpIniRequirement('xdebug.scream', false, true);
         $this->addPhpIniRecommendation('xdebug.max_nesting_level', create_function('$cfgValue', 'return $cfgValue > 100;'), true, 'xdebug.max_nesting_level should be above 100 in php.ini', '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.');
     }
     $pcreVersion = defined('PCRE_VERSION') ? (double) PCRE_VERSION : null;
     $this->addRequirement(null !== $pcreVersion, 'PCRE extension must be available', 'Install the <strong>PCRE</strong> extension (version 8.0+).');
     if (extension_loaded('mbstring')) {
         $this->addPhpIniRequirement('mbstring.func_overload', create_function('$cfgValue', 'return (int) $cfgValue === 0;'), true, 'string functions should not be overloaded', '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.');
     }
     /* optional recommendations follow */
     if (file_exists(__DIR__ . '/../vendor/composer')) {
         require_once __DIR__ . '/../vendor/autoload.php';
         try {
             $r = new ReflectionClass('Sensio\\Bundle\\DistributionBundle\\SensioDistributionBundle');
             $contents = file_get_contents(dirname($r->getFileName()) . '/Resources/skeleton/app/SymfonyRequirements.php');
         } catch (ReflectionException $e) {
             $contents = '';
         }
         $this->addRecommendation(file_get_contents(__FILE__) === $contents, 'Requirements file should be up-to-date', 'Your requirements file is outdated. Run composer install and re-check your configuration.');
     }
     $this->addRecommendation(version_compare($installedPhpVersion, '5.3.4', '>='), 'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions', '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.');
     $this->addRecommendation(version_compare($installedPhpVersion, '5.3.8', '>='), 'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156', 'Install PHP 5.3.8 or newer if your project uses annotations.');
     $this->addRecommendation(version_compare($installedPhpVersion, '5.4.0', '!='), 'You should not use PHP 5.4.0 due to the PHP bug #61453', '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.');
     $this->addRecommendation(version_compare($installedPhpVersion, '5.4.11', '>='), '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)', 'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.');
     $this->addRecommendation(version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<') || version_compare($installedPhpVersion, '5.4.8', '>='), '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', 'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.');
     if (null !== $pcreVersion) {
         $this->addRecommendation($pcreVersion >= 8.0, sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion), '<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.');
     }
     $this->addRecommendation(class_exists('DomDocument'), 'PHP-DOM and PHP-XML modules should be installed', 'Install and enable the <strong>PHP-DOM</strong> and the <strong>PHP-XML</strong> modules.');
     $this->addRecommendation(function_exists('mb_strlen'), 'mb_strlen() should be available', 'Install and enable the <strong>mbstring</strong> extension.');
     $this->addRecommendation(function_exists('iconv'), 'iconv() should be available', 'Install and enable the <strong>iconv</strong> extension.');
     $this->addRecommendation(function_exists('utf8_decode'), 'utf8_decode() should be available', 'Install and enable the <strong>XML</strong> extension.');
     $this->addRecommendation(function_exists('filter_var'), 'filter_var() should be available', 'Install and enable the <strong>filter</strong> extension.');
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $this->addRecommendation(function_exists('posix_isatty'), 'posix_isatty() should be available', 'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).');
     }
     $this->addRecommendation(extension_loaded('intl'), 'intl extension should be available', 'Install and enable the <strong>intl</strong> extension (used for validators).');
     if (extension_loaded('intl')) {
         // in some WAMP server installations, new Collator() returns null
         $this->addRecommendation(null !== new Collator('fr_FR'), 'intl extension should be correctly configured', 'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.');
         // check for compatible ICU versions (only done when you have the intl extension)
         if (defined('INTL_ICU_VERSION')) {
             $version = INTL_ICU_VERSION;
         } else {
             $reflector = new ReflectionExtension('intl');
             ob_start();
             $reflector->info();
             $output = strip_tags(ob_get_clean());
             preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
             $version = $matches[1];
         }
         $this->addRecommendation(version_compare($version, '4.0', '>='), 'intl ICU version should be at least 4+', 'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).');
         $this->addPhpIniRecommendation('intl.error_level', create_function('$cfgValue', 'return (int) $cfgValue === 0;'), true, 'intl.error_level should be 0 in php.ini', '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.');
     }
     $accelerator = extension_loaded('eaccelerator') && ini_get('eaccelerator.enable') || extension_loaded('apc') && ini_get('apc.enabled') || extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable') || extension_loaded('Zend OPcache') && ini_get('opcache.enable') || extension_loaded('xcache') && ini_get('xcache.cacher') || extension_loaded('wincache') && ini_get('wincache.ocenabled');
     $this->addRecommendation($accelerator, 'a PHP accelerator should be installed', 'Install and/or enable a <strong>PHP accelerator</strong> (highly recommended).');
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $this->addRecommendation($this->getRealpathCacheSize() >= 5 * 1024 * 1024, 'realpath_cache_size should be at least 5M in php.ini', '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.');
     }
     $this->addPhpIniRecommendation('short_open_tag', false);
     $this->addPhpIniRecommendation('magic_quotes_gpc', false, true);
     $this->addPhpIniRecommendation('register_globals', false, true);
     $this->addPhpIniRecommendation('session.auto_start', false);
     $this->addRecommendation(class_exists('PDO'), 'PDO should be installed', 'Install <strong>PDO</strong> (mandatory for Doctrine).');
     if (class_exists('PDO')) {
         $drivers = PDO::getAvailableDrivers();
         $this->addRecommendation(count($drivers) > 0, sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'), 'Install <strong>PDO drivers</strong> (mandatory for Doctrine).');
     }
 }
Example #22
0
 public function printInfo()
 {
     $info = [];
     $ion = new \ReflectionExtension('ion');
     $info[] = $ion->info();
     foreach ($ion->getINIEntries() as $ini => $value) {
         $info[] = "ini {$ini} = " . var_export($value, true);
     }
     foreach ($ion->getConstants() as $constant => $value) {
         $info[] = "const {$constant} = " . var_export($value, true);
     }
     foreach ($ion->getFunctions() as $function) {
         $info[] = $this->_scanFunction($function);
     }
     foreach ($ion->getClasses() as $class) {
         $mods = [];
         if ($class->isFinal()) {
             $mods[] = "final";
         }
         if ($class->isInterface()) {
             $mods[] = "interface";
         } elseif ($class->isTrait()) {
             $mods[] = "trait";
         } else {
             if ($class->isAbstract()) {
                 $mods[] = "abstract";
             }
             $mods[] = "class";
         }
         $info[] = implode(' ', $mods) . " {$class->name} {";
         if ($class->getParentClass()) {
             $info[] = "  extends {$class->getParentClass()->name}";
         }
         foreach ($class->getInterfaceNames() as $interface) {
             $info[] = "  implements {$interface}";
         }
         foreach ($class->getTraitNames() as $trait) {
             $info[] = "  use {$trait}";
         }
         foreach ($class->getConstants() as $constant => $value) {
             $info[] = "  const {$class->name}::{$constant} = " . var_export($value, true);
         }
         foreach ($class->getProperties() as $prop_name => $prop) {
             /** @var ReflectionProperty $prop */
             $mods = implode(' ', Reflection::getModifierNames($prop->getModifiers()));
             if ($prop->class !== $class->name) {
                 $info[] = "  prop {$mods} {$prop->class}::\${$prop->name}";
             } else {
                 $info[] = "  prop {$mods} \${$prop->name}";
             }
         }
         foreach ($class->getMethods() as $method) {
             $info[] = $this->_scanFunction($method, $class->name);
         }
         $info[] = "}";
     }
     echo implode("\n", $info) . "\n";
 }
Example #23
0
        $reqMessages[3][] = installer_t($message);
    } else {
        $requirements['environment']['php_server_superglobal'] = 1;
    }
}
// Check for existence of Reflection class
$requirements['extensions']['pcre'] = 0;
$requirements['environment']['pcre_version'] = 0;
if (!($requirements['classes']['Reflection'] = class_exists('Reflection', false))) {
    $reqMessages[3][] = '<a href="http://php.net/manual/class.reflectionclass.php">PHP reflection class</a>: ' . $rbm;
} else {
    if ($requirements['extensions']['pcre'] = extension_loaded("pcre")) {
        // Check PCRE library version
        $pcreReflector = new ReflectionExtension("pcre");
        ob_start();
        $pcreReflector->info();
        $pcreInfo = ob_get_clean();
        $matches = array();
        preg_match("/([\\d\\.]+) \\d{4,}-\\d{1,2}-\\d{1,2}/", $pcreInfo, $matches);
        $thisVer = $matches[1];
        $reqVer = '7.4';
        if (!($requirements['environment']['pcre_version'] = version_compare($thisVer, $reqVer) >= 0)) {
            $reqMessages[3][] = strtr(installer_t("The version of the PCRE library included in this build of PHP is {thisVer}, but {reqVer} or later is required."), array('{thisVer}' => $thisVer, '{reqVer}' => $reqVer));
        }
    } else {
        $reqMessages[3][] = '<a href="http://www.php.net/manual/book.pcre.php">PCRE extension</a>: ' . $rbm;
    }
}
// Check for SPL extension
if (!($requirements['extensions']['SPL'] = extension_loaded("SPL"))) {
    $reqMessages[3][] = '<a href="http://www.php.net/manual/book.spl.php">SPL</a>: ' . $rbm;
Example #24
0
 /**
  * Returns the version of the installed ICU library.
  *
  * @return null|string The ICU version or NULL if it could not be determined.
  */
 public static function getIcuVersion()
 {
     if (false === self::$icuVersion) {
         if (!self::isExtensionLoaded()) {
             self::$icuVersion = self::getIcuStubVersion();
         } elseif (defined('INTL_ICU_VERSION')) {
             self::$icuVersion = INTL_ICU_VERSION;
         } else {
             try {
                 $reflector = new \ReflectionExtension('intl');
                 ob_start();
                 $reflector->info();
                 $output = strip_tags(ob_get_clean());
                 preg_match('/^ICU version (?:=>)?(.*)$/m', $output, $matches);
                 self::$icuVersion = trim($matches[1]);
             } catch (\ReflectionException $e) {
                 self::$icuVersion = null;
             }
         }
     }
     return self::$icuVersion;
 }
Example #25
0
 /**
  * Returns the ICU Data version as defined by the intl extension
  *
  * @return string|null The ICU Data version
  */
 public static function getIntlIcuDataVersion()
 {
     if (defined('INTL_ICU_DATA_VERSION')) {
         return INTL_ICU_DATA_VERSION;
     }
     try {
         $reflector = new \ReflectionExtension('intl');
     } catch (\ReflectionException $e) {
         return;
     }
     ob_start();
     $reflector->info();
     $output = strip_tags(ob_get_clean());
     preg_match('/^ICU Data version (?:=>)?(.*)$/m', $output, $matches);
     return trim($matches[1]);
 }
Example #26
0
 public function run()
 {
     $params = $this->getParameters();
     $extension = $params->get('extension', $this->getName());
     if (empty($extension)) {
         throw new \InvalidArgumentException('Parameter "extension" must be a php extension name to check on class "' . get_class($this) . '".');
     }
     $custom_name = $params->get('custom_name', $this->getName());
     $help = $params->get('help');
     $wanted_version = $params->get('version');
     $loaded = $params->get('loaded');
     $regex = $params->get('regex');
     $debug_mode = $params->get('debug', false);
     $okay = true;
     try {
         // GATHER DATA
         $extension_class = new \ReflectionExtension($extension);
         $extension_version = $extension_class->getVersion();
         ob_start();
         $extension_class->info();
         $info = ob_get_clean();
         if ($debug_mode) {
             var_dump($extension, $extension_version, $info, '============================================');
         }
         // OPTIONS CHECK
         if (null !== $regex) {
             if (is_array($regex)) {
                 // multiple regular expressions
                 foreach ($regex as $key => $test) {
                     if (!is_string($test)) {
                         throw new \InvalidArgumentException('The extension requirements must be strings that are valid regular expressions.');
                     }
                     if (strpos($test, '(?P<contains>') !== false && !is_numeric($key)) {
                         // explode "name" attribute & match each item in the named capturing group "contains" w/ it
                         $values = explode(',', $key);
                         $values = array_map('trim', $values);
                         $regex_matches = preg_match($test, $info, $matches);
                         if ($regex_matches) {
                             $pool = $matches['contains'];
                             foreach ($values as $value) {
                                 if (strpos($pool, $value) === false) {
                                     $this->addError('The extension "' . $extension . '" does not have "' . $value . '" support.', $custom_name);
                                     $okay = false;
                                 } else {
                                     $this->addInfo('The extension "' . $extension . '" does have "' . $value . '" support.', $custom_name);
                                 }
                             }
                         }
                     } else {
                         // just preg_match the given regex string
                         if (!preg_match($test, $info)) {
                             $this->addError('The extension "' . $extension . '" does not match the requirement: ' . $test, $custom_name);
                             $okay = false;
                         } else {
                             $this->addInfo('The extension "' . $extension . '" does match the requirement: ' . $test, $custom_name);
                         }
                     }
                 }
             } else {
                 // single regex to test
                 if (!preg_match($regex, $info)) {
                     $this->addError('The extension "' . $extension . '" does not match the requirement: ' . $regex, $custom_name);
                     $okay = false;
                 } else {
                     $this->addInfo('The extension "' . $extension . '" does match the requirement: ' . $regex, $custom_name);
                 }
             }
         }
         // VERSION COMPARISON
         if (null !== $wanted_version) {
             if (is_array($wanted_version) && array_key_exists('regex', $wanted_version) && array_key_exists('value', $wanted_version)) {
                 $regex_matches = preg_match($wanted_version['regex'], $info, $matches);
                 if (!$regex_matches || !array_key_exists('version', $matches)) {
                     $this->addError('Version information of "' . $extension . '" could not be determined, as ' . 'the given regular expression did not match: "' . $wanted_version['regex'] . PHP_EOL . 'Remember that you need a valid named capturing group "version" in the ' . 'regexp, e.g.: #libXML (Compiled )?Version => (?P<version>\\d+.+?)\\n#' . PHP_EOL . 'Set the parameter "debug" to true to work on that matching regex.', $custom_name);
                     $okay = false;
                 } elseif ($regex_matches) {
                     $operator = PhpSettingCheck::getOperator($wanted_version['value']);
                     $wanted_version_without_operator = ltrim($wanted_version['value'], '<>!=');
                     if (!version_compare($matches['version'], $wanted_version_without_operator, $operator)) {
                         $this->addError('Version of "' . $extension . '" should be "' . $wanted_version['value'] . '", but is: "' . $matches['version'] . '"', $custom_name);
                         $okay = false;
                     } else {
                         $this->addInfo('Version of extension "' . $extension . '" is "' . $matches['version'] . '" ("' . $wanted_version['value'] . '").', $custom_name);
                     }
                 }
             } elseif (is_string($wanted_version)) {
                 $operator = PhpSettingCheck::getOperator($wanted_version);
                 $wanted_version_without_operator = ltrim($wanted_version, '<>!=');
                 if (!version_compare($extension_version, $wanted_version_without_operator, $operator)) {
                     $this->addError('Version of "' . $extension . '" should be "' . $wanted_version . '", but is: "' . $extension_version . '"', $custom_name);
                     $okay = false;
                 } else {
                     $this->addInfo('Version of extension "' . $extension . '" is "' . $extension_version . '"' . ' ("' . $wanted_version . '").', $custom_name);
                 }
             } else {
                 throw new \InvalidArgumentException('A nested version parameter needs exactly two keys: ' . PHP_EOL . '- "regex" with one matching named capturing group "version" (e.g. ' . '"#libXML (Compiled )?Version => (?P<version>\\d+.+?)\\n#") and ' . PHP_EOL . '- "value" to compare the named capturing group content against' . '(version comparison, e.g. ">=2.6.26").');
             }
         }
         // LOADED CHECK
         if (null !== $loaded) {
             if ($loaded != extension_loaded($extension)) {
                 $loaded_string = $loaded ? 'not loaded, but should be.' : 'loaded, but should not be.';
                 $this->addError('The extension "' . $extension . '" is ' . $loaded_string, $custom_name);
                 $okay = false;
             } else {
                 $this->addInfo('The extension "' . $extension . '" is loaded.', $custom_name);
             }
         }
     } catch (\ReflectionException $e) {
         $this->addError('There is no extension with the name "' . $extension . '".', $custom_name);
         $okay = false;
     }
     if (!$okay && $help !== null) {
         $this->addNotice($help, $custom_name);
     }
     if ($okay) {
         $this->addInfo('Extension "' . $extension . '" is available and correct.', $custom_name);
     }
     return $okay;
 }