PhpBrew\Extension\ExtensionFactory::lookupRecursive PHP Method

lookupRecursive() public static method

public static lookupRecursive ( $packageName, array $lookupDirs = [], $fallback = true )
$lookupDirs array
    public static function lookupRecursive($packageName, array $lookupDirs = array(), $fallback = true)
    {
        if ($fallback) {
            // Always push the PHP source directory to the end of the list for the fallback.
            $lookupDirs[] = Config::getBuildDir() . DIRECTORY_SEPARATOR . Config::getCurrentPhpName() . DIRECTORY_SEPARATOR . 'ext' . DIRECTORY_SEPARATOR . $packageName;
        }
        foreach ($lookupDirs as $lookupDir) {
            if (!file_exists($lookupDir)) {
                continue;
            }
            if ($ext = self::createFromDirectory($packageName, $lookupDir)) {
                return $ext;
            }
            /*
             * FOLLOW_SYMLINKS is available from 5.2.11, 5.3.1
             */
            $di = new RecursiveDirectoryIterator($lookupDir, RecursiveDirectoryIterator::SKIP_DOTS);
            $it = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
            /*
             * Search for config.m4 or config0.m4 and use them to determine
             * the directory of the extension's source, because it's not always
             * the root directory in the ext archive (example xhprof)
             */
            foreach ($it as $fileinfo) {
                if (!$fileinfo->isDir()) {
                    continue;
                }
                if ($ext = self::createFromDirectory($packageName, $fileinfo->getPathName())) {
                    return $ext;
                }
            }
        }
    }

Usage Example

Beispiel #1
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);
 }
All Usage Examples Of PhpBrew\Extension\ExtensionFactory::lookupRecursive