findLatestPhpVersion() public static method

public static findLatestPhpVersion ( $version = null )
Beispiel #1
0
 public function execute($extName, $version = 'stable')
 {
     $logger = $this->getLogger();
     $extensions = array();
     if (Utils::startsWith($extName, '+')) {
         $config = Config::getConfigParam('extensions');
         $extName = ltrim($extName, '+');
         if (isset($config[$extName])) {
             foreach ($config[$extName] as $extensionName => $extOptions) {
                 $args = explode(' ', $extOptions);
                 $extensions[$extensionName] = $this->getExtData($args);
             }
         } else {
             $logger->info('Extension set name not found. Have you configured it at the config.yaml file?');
         }
     } else {
         $args = array_slice(func_get_args(), 1);
         $extensions[$extName] = $this->getExtData($args);
     }
     if ($this->options->{'php-version'} !== null) {
         $phpVersion = Utils::findLatestPhpVersion($this->options->{'php-version'});
         Config::setPhpVersion($phpVersion);
     }
     foreach ($extensions as $extensionName => $extData) {
         $extension = new Extension($extensionName, $logger);
         $extension->install($extData->version, $extData->options);
     }
     Config::useSystemPhpVersion();
 }
Beispiel #2
0
 public function execute($version = null)
 {
     // get current version
     if (!$version) {
         $version = getenv('PHPBREW_PHP');
     }
     // $currentVersion;
     $root = Config::getPhpbrewRoot();
     $home = Config::getPhpbrewHome();
     $lookup = getenv('PHPBREW_LOOKUP_PREFIX');
     // $versionBuildPrefix = Config::getVersionBuildPrefix($version);
     // $versionBinPath     = Config::getVersionBinPath($version);
     echo "export PHPBREW_ROOT={$root}\n";
     echo "export PHPBREW_HOME={$home}\n";
     echo "export PHPBREW_LOOKUP_PREFIX={$lookup}\n";
     if ($version !== false) {
         // checking php version exists
         $version = Utils::findLatestPhpVersion($version);
         $targetPhpBinPath = Config::getVersionBinPath($version);
         if (!is_dir($targetPhpBinPath)) {
             throw new Exception("# php version: " . $version . " not exists.");
         }
         echo 'export PHPBREW_PHP=' . $version . "\n";
         echo 'export PHPBREW_PATH=' . ($version ? Config::getVersionBinPath($version) : '') . "\n";
     }
 }
Beispiel #3
0
 public function execute()
 {
     if ($this->options->{'php'} !== null) {
         $php = Utils::findLatestPhpVersion($this->options->{'php'});
     } else {
         $php = Config::getCurrentPhpName();
     }
     $buildDir = Config::getBuildDir();
     $extDir = $buildDir . DIRECTORY_SEPARATOR . $php . DIRECTORY_SEPARATOR . 'ext';
     // listing all local extensions
     if (version_compare('php-' . phpversion(), $php, '==')) {
         $loaded = array_map('strtolower', get_loaded_extensions());
     } else {
         $this->logger->info('PHP version is different from current active version.');
         $this->logger->info('Only available extensions are listed.');
         $this->logger->info('You will not see which of them are loaded.');
         $loaded = array();
     }
     // list for extensions which are not enabled
     $extensions = array();
     if (is_dir($extDir)) {
         $fp = opendir($extDir);
         if ($fp !== false) {
             while ($file = readdir($fp)) {
                 if ($file === '.' || $file === '..') {
                     continue;
                 }
                 if (is_file($extDir . '/' . $file)) {
                     continue;
                 }
                 $n = strtolower(preg_replace('#-[\\d\\.]+$#', '', $file));
                 if (in_array($n, $loaded)) {
                     continue;
                 }
                 $extensions[] = $n;
             }
             sort($loaded);
             sort($extensions);
             closedir($fp);
         }
     }
     $this->logger->info('Loaded extensions:');
     foreach ($loaded as $ext) {
         $this->logger->info("  [*] {$ext}");
     }
     $this->logger->info('Available extensions:');
     foreach ($extensions as $ext) {
         $this->logger->info("  [ ] {$ext}");
     }
 }
Beispiel #4
0
 public function testFindLatestPhpVersion()
 {
     $this->markTestSkipped("We should use a virtual file system here (vsfStream)");
     $buildDir = Config::getBuildDir();
     $paths = array();
     $paths[] = $buildDir . DIRECTORY_SEPARATOR . 'php-12.3.4';
     $paths[] = $buildDir . DIRECTORY_SEPARATOR . 'php-12.3.6';
     // Create paths
     foreach ($paths as $path) {
         if (!is_dir($path)) {
             mkdir($path);
         }
     }
     is('12.3.6', Utils::findLatestPhpVersion('12'));
     is('12.3.6', Utils::findLatestPhpVersion('12.3'));
     is('12.3.4', Utils::findLatestPhpVersion('12.3.4'));
     is(false, Utils::findLatestPhpVersion('11'));
     // Cleanup paths
     foreach ($paths as $path) {
         if (is_dir($path)) {
             rmdir($path);
         }
     }
 }