当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::isLocalPath方法代码示例

本文整理汇总了PHP中Composer\Util\Filesystem::isLocalPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::isLocalPath方法的具体用法?PHP Filesystem::isLocalPath怎么用?PHP Filesystem::isLocalPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Util\Filesystem的用法示例。


在下文中一共展示了Filesystem::isLocalPath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * {@inheritDoc}
  */
 public function update(PackageInterface $initial, PackageInterface $target, $path)
 {
     if (!$target->getSourceReference()) {
         throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
     }
     $name = $target->getName();
     if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
         $from = $initial->getSourceReference();
         $to = $target->getSourceReference();
         $name .= ' ' . $initial->getPrettyVersion();
     } else {
         $from = $initial->getFullPrettyVersion();
         $to = $target->getFullPrettyVersion();
     }
     $this->io->writeError("  - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
     $urls = $target->getSourceUrls();
     while ($url = array_shift($urls)) {
         try {
             if (Filesystem::isLocalPath($url)) {
                 $url = realpath($url);
             }
             $this->doUpdate($initial, $target, $path, $url);
             break;
         } catch (\Exception $e) {
             if ($this->io->isDebug()) {
                 $this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('    Failed, trying the next URL');
             } else {
                 throw $e;
             }
         }
     }
     $this->io->writeError('');
 }
开发者ID:linearsoft,项目名称:composer-svn-export,代码行数:38,代码来源:Downloader.php

示例2: update

 public function update(PackageInterface $initial, PackageInterface $target, $path)
 {
     if (!$target->getSourceReference()) {
         throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
     }
     $name = $target->getName();
     if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
         if ($target->getSourceType() === 'svn') {
             $from = $initial->getSourceReference();
             $to = $target->getSourceReference();
         } else {
             $from = substr($initial->getSourceReference(), 0, 7);
             $to = substr($target->getSourceReference(), 0, 7);
         }
         $name .= ' ' . $initial->getPrettyVersion();
     } else {
         $from = VersionParser::formatVersion($initial);
         $to = VersionParser::formatVersion($target);
     }
     $this->io->writeError("  - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
     $this->cleanChanges($initial, $path, true);
     $urls = $target->getSourceUrls();
     while ($url = array_shift($urls)) {
         try {
             if (Filesystem::isLocalPath($url)) {
                 $url = realpath($url);
             }
             $this->doUpdate($initial, $target, $path, $url);
             break;
         } catch (\Exception $e) {
             if ($this->io->isDebug()) {
                 $this->io->writeError('Failed: [' . get_class($e) . '] ' . $e->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('    Failed, trying the next URL');
             } else {
                 $this->reapplyChanges($path);
                 throw $e;
             }
         }
     }
     $this->reapplyChanges($path);
     if ($this->io->isVerbose()) {
         $message = 'Pulling in changes:';
         $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
         if (!trim($logs)) {
             $message = 'Rolling back changes:';
             $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
         }
         if (trim($logs)) {
             $logs = implode("\n", array_map(function ($line) {
                 return '      ' . $line;
             }, explode("\n", $logs)));
             $this->io->writeError('    ' . $message);
             $this->io->writeError($logs);
         }
     }
     $this->io->writeError('');
 }
开发者ID:VicDeo,项目名称:poc,代码行数:58,代码来源:VcsDownloader.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param array            $repoConfig       The repository configuration
  * @param IOInterface      $io               The IO instance
  * @param Config           $config           The composer configuration
  * @param ProcessExecutor  $process          Process instance, injectable for mocking
  * @param RemoteFilesystem $remoteFilesystem Remote Filesystem, injectable for mocking
  */
 public final function __construct(array $repoConfig, IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null)
 {
     if (Filesystem::isLocalPath($repoConfig['url'])) {
         $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
     }
     $this->url = $repoConfig['url'];
     $this->originUrl = $repoConfig['url'];
     $this->repoConfig = $repoConfig;
     $this->io = $io;
     $this->config = $config;
     $this->process = $process ?: new ProcessExecutor($io);
     $this->remoteFilesystem = $remoteFilesystem ?: new RemoteFilesystem($io, $config);
 }
开发者ID:hanovruslan,项目名称:composer,代码行数:22,代码来源:VcsDriver.php

示例4: supports

 /**
  * {@inheritDoc}
  */
 public static function supports(IOInterface $io, Config $config, $url, $deep = false)
 {
     if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?bitbucket.org|https://(?:.*?)\\.kilnhg.com)#i', $url)) {
         return true;
     }
     // local filesystem
     if (Filesystem::isLocalPath($url)) {
         $url = Filesystem::getPlatformPath($url);
         if (!is_dir($url)) {
             throw new \RuntimeException('Directory does not exist: ' . $url);
         }
         $process = new ProcessExecutor();
         // check whether there is a hg repo in that path
         if ($process->execute('hg summary', $output, $url) === 0) {
             return true;
         }
     }
     if (!$deep) {
         return false;
     }
     $processExecutor = new ProcessExecutor();
     $exit = $processExecutor->execute(sprintf('hg identify %s', ProcessExecutor::escape($url)), $ignored);
     return $exit === 0;
 }
开发者ID:composer-fork,项目名称:composer,代码行数:27,代码来源:HgDriver.php

示例5: supports

 /**
  * {@inheritDoc}
  */
 public static function supports(IOInterface $io, Config $config, $url, $deep = false)
 {
     if (preg_match('#(^git://|\\.git/?$|git(?:olite)?@|//git\\.|//github.com/)#i', $url)) {
         return true;
     }
     // local filesystem
     if (Filesystem::isLocalPath($url)) {
         $url = Filesystem::getPlatformPath($url);
         if (!is_dir($url)) {
             return false;
         }
         $process = new ProcessExecutor($io);
         // check whether there is a git repo in that path
         if ($process->execute('git tag', $output, $url) === 0) {
             return true;
         }
     }
     if (!$deep) {
         return false;
     }
     $process = new ProcessExecutor($io);
     if ($process->execute('git ls-remote --heads ' . ProcessExecutor::escape($url), $output) === 0) {
         return true;
     }
     return false;
 }
开发者ID:neon64,项目名称:composer,代码行数:29,代码来源:GitDriver.php

示例6: supports

 /**
  * {@inheritDoc}
  */
 public static function supports(IOInterface $io, Config $config, $url, $deep = false)
 {
     $url = self::normalizeUrl($url);
     if (preg_match('#(^svn://|^svn\\+ssh://|svn\\.)#i', $url)) {
         return true;
     }
     // proceed with deep check for local urls since they are fast to process
     if (!$deep && !Filesystem::isLocalPath($url)) {
         return false;
     }
     $processExecutor = new ProcessExecutor();
     $exit = $processExecutor->execute("svn info --non-interactive {$url}", $ignoredOutput);
     if ($exit === 0) {
         // This is definitely a Subversion repository.
         return true;
     }
     if (false !== stripos($processExecutor->getErrorOutput(), 'authorization failed:')) {
         // This is likely a remote Subversion repository that requires
         // authentication. We will handle actual authentication later.
         return true;
     }
     return false;
 }
开发者ID:composer-fork,项目名称:composer,代码行数:26,代码来源:SvnDriver.php

示例7: update

 /**
  * {@inheritDoc}
  */
 public function update(PackageInterface $initial, PackageInterface $target, $path)
 {
     if (!$target->getSourceReference()) {
         throw new \InvalidArgumentException('Package ' . $target->getPrettyName() . ' is missing reference information');
     }
     $name = $target->getName();
     if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
         if ($target->getSourceType() === 'svn') {
             $from = $initial->getSourceReference();
             $to = $target->getSourceReference();
         } else {
             $from = substr($initial->getSourceReference(), 0, 7);
             $to = substr($target->getSourceReference(), 0, 7);
         }
         $name .= ' ' . $initial->getPrettyVersion();
     } else {
         $from = $initial->getFullPrettyVersion();
         $to = $target->getFullPrettyVersion();
     }
     $this->io->writeError("  - Updating <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>)");
     $this->cleanChanges($initial, $path, true);
     $urls = $target->getSourceUrls();
     $exception = null;
     while ($url = array_shift($urls)) {
         try {
             if (Filesystem::isLocalPath($url)) {
                 $url = realpath($url);
             }
             $this->doUpdate($initial, $target, $path, $url);
             $exception = null;
             break;
         } catch (\Exception $exception) {
             // rethrow phpunit exceptions to avoid hard to debug bug failures
             if ($exception instanceof \PHPUnit_Framework_Exception) {
                 throw $exception;
             }
             if ($this->io->isDebug()) {
                 $this->io->writeError('Failed: [' . get_class($exception) . '] ' . $exception->getMessage());
             } elseif (count($urls)) {
                 $this->io->writeError('    Failed, trying the next URL');
             }
         }
     }
     $this->reapplyChanges($path);
     // print the commit logs if in verbose mode and VCS metadata is present
     // because in case of missing metadata code would trigger another exception
     if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
         $message = 'Pulling in changes:';
         $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
         if (!trim($logs)) {
             $message = 'Rolling back changes:';
             $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
         }
         if (trim($logs)) {
             $logs = implode("\n", array_map(function ($line) {
                 return '      ' . $line;
             }, explode("\n", $logs)));
             // escape angle brackets for proper output in the console
             $logs = str_replace('<', '\\<', $logs);
             $this->io->writeError('    ' . $message);
             $this->io->writeError($logs);
         }
     }
     if (!$urls && $exception) {
         throw $exception;
     }
     $this->io->writeError('');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:71,代码来源:VcsDownloader.php

示例8: supports

 /**
  * {@inheritDoc}
  */
 public static function supports(IOInterface $io, Config $config, $url, $deep = false)
 {
     if (preg_match('#(^git://|\\.git$|git(?:olite)?@|//git\\.|//github.com/)#i', $url)) {
         return true;
     }
     // local filesystem
     if (Filesystem::isLocalPath($url)) {
         if (!is_dir($url)) {
             throw new \RuntimeException('Directory does not exist: ' . $url);
         }
         $process = new ProcessExecutor();
         $url = str_replace('file://', '', $url);
         // check whether there is a git repo in that path
         if ($process->execute('git tag', $output, $url) === 0) {
             return true;
         }
     }
     if (!$deep) {
         return false;
     }
     // TODO try to connect to the server
     return false;
 }
开发者ID:aminembarki,项目名称:composer,代码行数:26,代码来源:GitDriver.php

示例9: supports

 /**
  * {@inheritDoc}
  */
 public static function supports(IOInterface $io, Config $config, $url, $deep = false)
 {
     if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\\.com|fossil\\.))#i', $url)) {
         return true;
     }
     if (preg_match('!/fossil/|\\.fossil!', $url)) {
         return true;
     }
     // local filesystem
     if (Filesystem::isLocalPath($url)) {
         $url = Filesystem::getPlatformPath($url);
         if (!is_dir($url)) {
             return false;
         }
         $process = new ProcessExecutor();
         // check whether there is a fossil repo in that path
         if ($process->execute('fossil info', $output, $url) === 0) {
             return true;
         }
     }
     return false;
 }
开发者ID:neon64,项目名称:composer,代码行数:25,代码来源:FossilDriver.php

示例10: supports

 public static function supports(IOInterface $io, Config $config, $url, $deep = false)
 {
     if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?bitbucket.org|https://(?:.*?)\\.kilnhg.com)#i', $url)) {
         return true;
     }
     if (Filesystem::isLocalPath($url)) {
         $url = Filesystem::getPlatformPath($url);
         if (!is_dir($url)) {
             return false;
         }
         $process = new ProcessExecutor();
         if ($process->execute('hg summary', $output, $url) === 0) {
             return true;
         }
     }
     if (!$deep) {
         return false;
     }
     $processExecutor = new ProcessExecutor();
     $exit = $processExecutor->execute(sprintf('hg identify %s', ProcessExecutor::escape($url)), $ignored);
     return $exit === 0;
 }
开发者ID:VicDeo,项目名称:poc,代码行数:22,代码来源:HgDriver.php

示例11: supports

 public static function supports(IOInterface $io, Config $config, $url, $deep = false)
 {
     $url = self::normalizeUrl($url);
     if (preg_match('#(^svn://|^svn\\+ssh://|svn\\.)#i', $url)) {
         return true;
     }
     if (!$deep && !Filesystem::isLocalPath($url)) {
         return false;
     }
     $processExecutor = new ProcessExecutor();
     $exit = $processExecutor->execute("svn info --non-interactive {$url}", $ignoredOutput);
     if ($exit === 0) {
         return true;
     }
     if (false !== stripos($processExecutor->getErrorOutput(), 'authorization failed:')) {
         return true;
     }
     return false;
 }
开发者ID:VicDeo,项目名称:poc,代码行数:19,代码来源:SvnDriver.php

示例12: initialize

 /**
  * {@inheritdoc}
  */
 public function initialize()
 {
     parent::initialize();
     $cacheUrl = Filesystem::isLocalPath($this->url) ? realpath($this->url) : $this->url;
     $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $cacheUrl));
 }
开发者ID:MvegaR,项目名称:ingSotfware,代码行数:9,代码来源:HgDriver.php

示例13: execute

 /**
  * @param InputInterface $input The input instance
  * @param OutputInterface $output The output instance
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $verbose = $input->getOption('verbose');
     $configFile = $input->getArgument('file');
     $packagesFilter = $input->getArgument('packages');
     $repositoryUrl = $input->getOption('repository-url');
     $skipErrors = (bool) $input->getOption('skip-errors');
     if ($repositoryUrl !== null && count($packagesFilter) > 0) {
         throw new \InvalidArgumentException('The arguments "package" and "repository-url" can not be used together.');
     }
     // load auth.json authentication information and pass it to the io interface
     $io = $this->getIO();
     $io->loadConfiguration($this->getConfiguration());
     if (preg_match('{^https?://}i', $configFile)) {
         $rfs = new RemoteFilesystem($io);
         $contents = $rfs->getContents(parse_url($configFile, PHP_URL_HOST), $configFile, false);
         $config = JsonFile::parseJson($contents, $configFile);
     } else {
         $file = new JsonFile($configFile);
         if (!$file->exists()) {
             $output->writeln('<error>File not found: ' . $configFile . '</error>');
             return 1;
         }
         $config = $file->read();
     }
     // disable packagist by default
     unset(Config::$defaultRepositories['packagist']);
     if (!($outputDir = $input->getOption('output-dir'))) {
         if (isset($config['output-dir'])) {
             $outputDir = $config['output-dir'];
         } elseif (Filesystem::isLocalPath($configFile)) {
             $outputDir = dirname(realpath($configFile));
         }
     }
     if (null === $outputDir) {
         throw new \InvalidArgumentException('The output dir must be specified by option --output-dir or be configured inside ' . $input->getArgument('file'));
     }
     $composer = $this->getApplication()->getComposer(true, $config);
     $packageSelection = new PackageSelection($output, $outputDir, $config, $skipErrors);
     if ($repositoryUrl !== null) {
         $packageSelection->setRepositoryFilter($repositoryUrl);
     } else {
         $packageSelection->setPackagesFilter($packagesFilter);
     }
     $packages = $packageSelection->select($composer, $verbose);
     if (isset($config['archive']['directory'])) {
         $downloads = new ArchiveBuilder($output, $outputDir, $config, $skipErrors);
         $downloads->setComposer($composer);
         $downloads->dump($packages);
     }
     if ($packageSelection->hasFilterForPackages() || $packageSelection->hasRepositoryFilter()) {
         // in case of an active filter we need to load the dumped packages.json and merge the
         // updated packages in
         $oldPackages = $packageSelection->load();
         $packages += $oldPackages;
         ksort($packages);
     }
     $packagesBuilder = new PackagesBuilder($output, $outputDir, $config, $skipErrors);
     $updated = $packagesBuilder->dump($packages);
     if (!$updated) {
         return;
     }
     if ($htmlView = !$input->getOption('no-html-output')) {
         $htmlView = !isset($config['output-html']) || $config['output-html'];
     }
     if ($htmlView) {
         $web = new WebBuilder($output, $outputDir, $config, $skipErrors);
         $web->setRootPackage($composer->getPackage());
         $web->dump($packages);
     }
 }
开发者ID:wenbinye,项目名称:satis,代码行数:75,代码来源:BuildCommand.php


注:本文中的Composer\Util\Filesystem::isLocalPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。