lookup() public static method

public static lookup ( $packageName, array $lookupDirectories = [], $fallback = true )
$lookupDirectories array
 /**
  * @dataProvider packageNameProvider
  */
 public function testInstallPackages($extensionName, $extensionVersion = 'latest')
 {
     $logger = new Logger();
     $logger->setDebug();
     $manager = new ExtensionManager($logger);
     $peclProvider = new PeclProvider();
     $downloader = new ExtensionDownloader($logger, new OptionResult());
     $peclProvider->setPackageName($extensionName);
     $downloader->download($peclProvider, $extensionVersion);
     $ext = ExtensionFactory::lookup($extensionName);
     $this->assertNotNull($ext);
     $manager->installExtension($ext, array());
 }
Esempio n. 2
0
 public function execute($extensionName)
 {
     if ($ext = ExtensionFactory::lookup($extensionName)) {
         $this->logger->info("Cleaning {$extensionName}...");
         $manager = new ExtensionManager($this->logger);
         if ($this->options->purge) {
             $manager->purgeExtension($ext);
         } else {
             $manager->cleanExtension($ext);
         }
         $this->logger->info('Done');
     }
 }
Esempio n. 3
0
 /**
  * @dataProvider packageNameProvider
  */
 public function testInstallPackages($build, $extensionName, $extensionVersion, $options)
 {
     if (!$build) {
         $this->markTestSkipped('skip extension build test');
         return;
     }
     $logger = new Logger();
     $logger->setDebug();
     $manager = new ExtensionManager($logger);
     $peclProvider = new PeclProvider();
     $downloader = new ExtensionDownloader($logger, new OptionResult());
     $peclProvider->setPackageName($extensionName);
     $downloader->download($peclProvider, $extensionVersion);
     $ext = ExtensionFactory::lookup($extensionName);
     $this->assertNotNull($ext);
     $manager->installExtension($ext, $options);
 }
Esempio n. 4
0
 public function execute($extensionName)
 {
     $ext = ExtensionFactory::lookup($extensionName);
     if (!$ext) {
         return $this->error("Extension {$extensionName} not found.");
     }
     $file = $ext->getConfigFilePath();
     $this->logger->info("Looking for {$file} file...");
     if (!file_exists($file)) {
         $file .= '.disabled';
         // try with ini.disabled file
         $this->logger->info("Looking for {$file} file...");
         if (!file_exists($file)) {
             $this->logger->warn("Sorry, I can't find the ini file for the requested extension: \"{$extensionName}\".");
             return;
         }
     }
     Utils::editor($file);
 }
Esempio n. 5
0
 public function execute($extensionName)
 {
     $ext = ExtensionFactory::lookup($extensionName);
     if (!$ext) {
         $ext = ExtensionFactory::lookupRecursive($extensionName);
     }
     // Extension not found, use pecl to download it.
     if (!$ext && $this->options->{'download'}) {
         $extensionList = new ExtensionList();
         // initial local list
         $extensionList->initLocalExtensionList($this->logger, $this->options);
         $hosting = $extensionList->exists($extensionName);
         $downloader = new ExtensionDownloader($this->logger, $this->options);
         $extDir = $downloader->download($hosting, 'latest');
         // Reload the extension
         $ext = ExtensionFactory::lookupRecursive($extensionName, array($extDir));
     }
     if (!$ext) {
         throw new Exception("{$extensionName} extension not found.");
     }
     $this->describeExtension($ext);
 }
Esempio n. 6
0
 public function testCleanExtension()
 {
     $ext = ExtensionFactory::lookup('xdebug', array(getenv('PHPBREW_EXTENSION_DIR')));
     $this->manager->cleanExtension($ext);
 }
Esempio n. 7
0
 public function execute($extName, $version = 'stable')
 {
     if ((preg_match('#^git://#', $extName) || preg_match('#\\.git$#', $extName)) && !preg_match("#github|bitbucket#", $extName)) {
         $pathinfo = pathinfo($extName);
         $repoUrl = $extName;
         $extName = $pathinfo['filename'];
         $extDir = Config::getBuildDir() . DIRECTORY_SEPARATOR . Config::getCurrentPhpName() . DIRECTORY_SEPARATOR . 'ext' . DIRECTORY_SEPARATOR . $extName;
         if (!file_exists($extDir)) {
             passthru("git clone {$repoUrl} {$extDir}", $ret);
             if ($ret != 0) {
                 return $this->logger->error('Clone failed.');
             }
         }
     }
     $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->getExtConfig($args);
             }
         } else {
             $this->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->getExtConfig($args);
     }
     $extensionList = new ExtensionList();
     $manager = new ExtensionManager($this->logger);
     foreach ($extensions as $extensionName => $extConfig) {
         $provider = $extensionList->exists($extensionName);
         if (!$provider) {
             throw new Exception("Could not find provider for {$extensionName}.");
         }
         $extensionName = $provider->getPackageName();
         $ext = ExtensionFactory::lookupRecursive($extensionName);
         $always_redownload = $this->options->{'pecl'} || $this->options->{'redownload'} || !$provider->isBundled($extensionName);
         // Extension not found, use pecl to download it.
         if (!$ext || $always_redownload) {
             // not every project has stable branch, using master as default version
             $args = array_slice(func_get_args(), 1);
             if (!isset($args[0]) || $args[0] != $extConfig->version) {
                 $extConfig->version = $provider->getDefaultVersion();
             }
             $extensionDownloader = new ExtensionDownloader($this->logger, $this->options);
             $extensionDownloader->download($provider, $extConfig->version);
             // Reload the extension
             if ($provider->shouldLookupRecursive()) {
                 $ext = ExtensionFactory::lookupRecursive($extensionName);
             } else {
                 $ext = ExtensionFactory::lookup($extensionName);
             }
             if ($ext) {
                 $extensionDownloader->renameSourceDirectory($ext);
             }
         }
         if (!$ext) {
             throw new Exception("{$extensionName} not found.");
         }
         $manager->installExtension($ext, $extConfig->options);
     }
 }
Esempio n. 8
0
 /**
  * Disable extensions known to conflict with current one
  */
 public function disableAntagonists(Extension $ext)
 {
     $name = $ext->getName();
     if (isset($this->conflicts[$name])) {
         $conflicts = $this->conflicts[$name];
         $this->logger->info("===> Applying conflicts resolution (" . implode(', ', $conflicts) . "):");
         foreach ($conflicts as $extensionName) {
             $ext = ExtensionFactory::lookup($extensionName);
             $this->disableExtension($ext);
         }
     }
 }
Esempio n. 9
0
 /**
  * @dataProvider extensionNameProvider
  */
 public function testGenericExtensionMetaInformation($extName)
 {
     $ext = ExtensionFactory::lookup($extName, array(getenv('PHPBREW_EXTENSION_DIR')));
     $this->assertInstanceOf('PhpBrew\\Extension\\Extension', $ext);
     $this->assertNotEmpty($ext->getName());
 }
Esempio n. 10
0
 public function execute($extName, $version = 'stable')
 {
     if (version_compare(PHP_VERSION, '7.0.0') > 0) {
         $this->logger->warn("Warning: Some extension won't be able to be built with php7. If the extension\nsupports php7 in another branch or new major version, you will need to specify\nthe branch name or version name explicitly.\n\nFor example, to install memcached extension for php7, use:\n\n    phpbrew ext install github:php-memcached-dev/php-memcached php7 -- --disable-memcached-sasl\n");
     }
     if (strtolower($extName) === 'apc' && version_compare(PHP_VERSION, '5.6.0') > 0) {
         $this->logger->warn('apc is not compatible with php 5.6+ versions, install apcu instead.');
     }
     // Detect protocol
     if ((preg_match('#^git://#', $extName) || preg_match('#\\.git$#', $extName)) && !preg_match('#github|bitbucket#', $extName)) {
         $pathinfo = pathinfo($extName);
         $repoUrl = $extName;
         $extName = $pathinfo['filename'];
         $extDir = Config::getBuildDir() . DIRECTORY_SEPARATOR . Config::getCurrentPhpName() . DIRECTORY_SEPARATOR . 'ext' . DIRECTORY_SEPARATOR . $extName;
         if (!file_exists($extDir)) {
             passthru("git clone {$repoUrl} {$extDir}", $ret);
             if ($ret != 0) {
                 return $this->logger->error('Clone failed.');
             }
         }
     }
     // Expand extensionset from config
     $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->getExtConfig($args);
             }
         } else {
             $this->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->getExtConfig($args);
     }
     $extensionList = new ExtensionList($this->logger, $this->options);
     $manager = new ExtensionManager($this->logger);
     foreach ($extensions as $extensionName => $extConfig) {
         $provider = $extensionList->exists($extensionName);
         if (!$provider) {
             throw new Exception("Could not find provider for {$extensionName}.");
         }
         $extensionName = $provider->getPackageName();
         $ext = ExtensionFactory::lookupRecursive($extensionName);
         $always_redownload = $this->options->{'pecl'} || $this->options->{'redownload'} || !$provider->isBundled($extensionName);
         // Extension not found, use pecl to download it.
         if (!$ext || $always_redownload) {
             // not every project has stable branch, using master as default version
             $args = array_slice(func_get_args(), 1);
             if (!isset($args[0]) || $args[0] != $extConfig->version) {
                 $extConfig->version = $provider->getDefaultVersion();
             }
             $extensionDownloader = new ExtensionDownloader($this->logger, $this->options);
             $extensionDownloader->download($provider, $extConfig->version);
             // Reload the extension
             if ($provider->shouldLookupRecursive()) {
                 $ext = ExtensionFactory::lookupRecursive($extensionName);
             } else {
                 $ext = ExtensionFactory::lookup($extensionName);
             }
             if ($ext) {
                 $extensionDownloader->renameSourceDirectory($ext);
             }
         }
         if (!$ext) {
             throw new Exception("{$extensionName} not found.");
         }
         $manager->installExtension($ext, $extConfig->options);
     }
 }