• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Util\ProcessExecutor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: installDependencies

 private static function installDependencies(IOInterface $io, $folder)
 {
     $io->write("[0;32mInstalling front end dependencies from package.json[0m");
     $proc = new ProcessExecutor();
     $proc->execute('cd ' . $folder . ' && npm install');
     $io->write("[0;32mFront end dependencies installed[0m");
 }
开发者ID:studionone,项目名称:Flint,代码行数:7,代码来源:NpmBridge.php


示例2: addComposerTime

 /**
  * Add time in composer.
  *
  * @param array           $composer
  * @param ProcessExecutor $process
  * @param string          $cmd
  * @param string          $repoDir
  * @param string          $datetimePrefix
  *
  * @return array The composer
  */
 protected static function addComposerTime(array $composer, ProcessExecutor $process, $cmd, $repoDir, $datetimePrefix = '')
 {
     if (!isset($composer['time'])) {
         $process->execute($cmd, $output, $repoDir);
         $date = new \DateTime($datetimePrefix . trim($output), new \DateTimeZone('UTC'));
         $composer['time'] = $date->format('Y-m-d H:i:s');
     }
     return $composer;
 }
开发者ID:MvegaR,项目名称:ingSotfware,代码行数:20,代码来源:ProcessUtil.php


示例3: determineLocalPackageReference

 private function determineLocalPackageReference()
 {
     $basePath = realpath(getcwd());
     if (is_dir($basePath . DIRECTORY_SEPARATOR . '.git')) {
         $process = new ProcessExecutor();
         if ($process->execute('git rev-parse HEAD', $output, $basePath) === 0) {
             return trim($output);
         }
     }
     // TODO: add support for other VCS'es
     return null;
 }
开发者ID:mcuelenaere,项目名称:composer-revision-plugin,代码行数:12,代码来源:Plugin.php


示例4: extract

 protected function extract($file, $path)
 {
     $processError = null;
     // Try to use unrar on *nix
     if (!Platform::isWindows()) {
         $command = 'unrar x ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
         if (0 === $this->process->execute($command, $ignoredOutput)) {
             return;
         }
         $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
     }
     if (!class_exists('RarArchive')) {
         // php.ini path is added to the error message to help users find the correct file
         $iniMessage = IniHelper::getMessage();
         $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n" . $iniMessage . "\n" . $processError;
         if (!Platform::isWindows()) {
             $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
         }
         throw new \RuntimeException($error);
     }
     $rarArchive = RarArchive::open($file);
     if (false === $rarArchive) {
         throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
     }
     $entries = $rarArchive->getEntries();
     if (false === $entries) {
         throw new \RuntimeException('Could not retrieve RAR archive entries');
     }
     foreach ($entries as $entry) {
         if (false === $entry->extract($path)) {
             throw new \RuntimeException('Could not extract entry');
         }
     }
     $rarArchive->close();
 }
开发者ID:Rudloff,项目名称:composer,代码行数:35,代码来源:RarDownloader.php


示例5: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('list')) {
         return $this->listScripts();
     } elseif (!$input->getArgument('script')) {
         throw new \RunTimeException('Missing required argument "script"');
     }
     $script = $input->getArgument('script');
     if (!in_array($script, $this->scriptEvents)) {
         if (defined('Composer\\Script\\ScriptEvents::' . str_replace('-', '_', strtoupper($script)))) {
             throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
         }
     }
     $composer = $this->getComposer();
     $hasListeners = $composer->getEventDispatcher()->hasEventListeners(new CommandEvent($script, $composer, $this->getIO()));
     if (!$hasListeners) {
         throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
     }
     $args = $input->getArgument('args');
     if (!is_null($timeout = $input->getOption('timeout'))) {
         if (!ctype_digit($timeout)) {
             throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
         }
         // Override global timeout set before in Composer by environment or config
         ProcessExecutor::setTimeout((int) $timeout);
     }
     return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args);
 }
开发者ID:alcaeus,项目名称:composer,代码行数:28,代码来源:RunScriptCommand.php


示例6: get

 protected function get($originUrl, $fileUrl, $options = [], $fileName = null, $progress = true)
 {
     if (strpos($fileUrl, 'ssh://') !== 0) {
         throw new \UnexpectedValueException("This does not appear to be a file that should be downloaded via ssh: {$fileUrl}");
     }
     // strip off the pseudo protocol
     $fileUrl = substr($fileUrl, 6);
     if ($this->io->isVerbose()) {
         $this->io->write("Downloading {$fileUrl} via ssh.");
     }
     // filename means we want to save
     if ($fileName) {
         $cmd = 'scp ' . ProcessExecutor::escape($fileUrl) . ' ' . ProcessExecutor::escape($fileName);
     } else {
         // otherwise just return the file contents
         list($host, $path) = explode(':', $fileUrl);
         $cmd = 'ssh ' . ProcessExecutor::escape($host) . ' ' . ProcessExecutor::escape('cat ' . ProcessExecutor::escape($path));
     }
     if ($progress) {
         $this->io->writeError('    Downloading: <comment>Connecting...</comment>', false);
     }
     // success?
     // @todo: do we need to catch any exceptions here?
     if ($this->process->execute($cmd, $output) === 0) {
         if ($progress) {
             $this->io->overwriteError('    Downloading: <comment>100%</comment>');
         }
         return $output;
     } else {
         // some sort of error - boo!
         throw new \RuntimeException("Could not download {$fileUrl}. " . $process->getErrorOutput());
     }
 }
开发者ID:balbuf,项目名称:composer-wp,代码行数:33,代码来源:SSHFilesystem.php


示例7: loadConfiguration

 /**
  * {@inheritDoc}
  */
 public function loadConfiguration(Config $config)
 {
     // reload oauth token from config if available
     if ($tokens = $config->get('github-oauth')) {
         foreach ($tokens as $domain => $token) {
             if (!preg_match('{^[a-z0-9]+$}', $token)) {
                 throw new \UnexpectedValueException('Your github oauth token for ' . $domain . ' contains invalid characters: "' . $token . '"');
             }
             $this->setAuthentication($domain, $token, 'x-oauth-basic');
         }
     }
     if ($tokens = $config->get('gitlab-oauth')) {
         foreach ($tokens as $domain => $token) {
             $this->setAuthentication($domain, $token, 'oauth2');
         }
     }
     // reload http basic credentials from config if available
     if ($creds = $config->get('http-basic')) {
         foreach ($creds as $domain => $cred) {
             $this->setAuthentication($domain, $cred['username'], $cred['password']);
         }
     }
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
 }
开发者ID:alancleaver,项目名称:composer,代码行数:28,代码来源:BaseIO.php


示例8: extract

 protected function extract($file, $path)
 {
     $processError = null;
     if (self::$hasSystemUnzip && !(class_exists('ZipArchive') && Platform::isWindows())) {
         $command = 'unzip ' . ProcessExecutor::escape($file) . ' -d ' . ProcessExecutor::escape($path);
         if (!Platform::isWindows()) {
             $command .= ' && chmod -R u+w ' . ProcessExecutor::escape($path);
         }
         try {
             if (0 === $this->process->execute($command, $ignoredOutput)) {
                 return;
             }
             $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
         } catch (\Exception $e) {
             $processError = 'Failed to execute ' . $command . "\n\n" . $e->getMessage();
         }
         if (!class_exists('ZipArchive')) {
             throw new \RuntimeException($processError);
         }
     }
     $zipArchive = new ZipArchive();
     if (true !== ($retval = $zipArchive->open($file))) {
         throw new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file) . "\n" . $processError), $retval);
     }
     if (true !== $zipArchive->extractTo($path)) {
         throw new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n" . $processError));
     }
     $zipArchive->close();
 }
开发者ID:neon64,项目名称:composer,代码行数:29,代码来源:ZipDownloader.php


示例9: deployLibraries

 /**
  * Moves front-end libraries to Lightning's installed directory.
  *
  * @param \Composer\Script\Event $event
  *   The script event.
  */
 public static function deployLibraries(Event $event)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     if (isset($extra['installer-paths'])) {
         foreach ($extra['installer-paths'] as $path => $criteria) {
             if (array_intersect(['drupal/lightning', 'type:drupal-profile'], $criteria)) {
                 $lightning = $path;
             }
         }
         if (isset($lightning)) {
             $lightning = str_replace('{$name}', 'lightning', $lightning);
             $executor = new ProcessExecutor($event->getIO());
             $output = NULL;
             $executor->execute('npm run install-libraries', $output, $lightning);
         }
     }
 }
开发者ID:sgrichards,项目名称:drupal-startup,代码行数:23,代码来源:ScriptHandler.php


示例10: createComposer

 /**
  * Creates a Composer instance
  *
  * @param IOInterface $io IO instance
  * @param mixed $localConfig either a configuration array or a filename to read from, if null it will read from the default filename
  * @return Composer
  */
 public function createComposer(IOInterface $io, $localConfig = null)
 {
     // load Composer configuration
     if (null === $localConfig) {
         $localConfig = getenv('COMPOSER') ?: 'composer.json';
     }
     if (is_string($localConfig)) {
         $composerFile = $localConfig;
         $file = new JsonFile($localConfig, new RemoteFilesystem($io));
         if (!$file->exists()) {
             if ($localConfig === 'composer.json') {
                 $message = 'Composer could not find a composer.json file in ' . getcwd();
             } else {
                 $message = 'Composer could not find the config file: ' . $localConfig;
             }
             $instructions = 'To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section';
             throw new \InvalidArgumentException($message . PHP_EOL . $instructions);
         }
         $file->validateSchema(JsonFile::LAX_SCHEMA);
         $localConfig = $file->read();
     }
     // Configuration defaults
     $config = $this->createConfig();
     $config->merge($localConfig);
     $vendorDir = $config->get('vendor-dir');
     $binDir = $config->get('bin-dir');
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
     // initialize repository manager
     $rm = $this->createRepositoryManager($io, $config);
     // load default repository unless it's explicitly disabled
     $localConfig = $this->addPackagistRepository($localConfig);
     // load local repository
     $this->addLocalRepository($rm, $vendorDir);
     // load package
     $loader = new Package\Loader\RootPackageLoader($rm);
     $package = $loader->load($localConfig);
     // initialize download manager
     $dm = $this->createDownloadManager($io);
     // initialize installation manager
     $im = $this->createInstallationManager($rm, $dm, $vendorDir, $binDir, $io);
     // purge packages if they have been deleted on the filesystem
     $this->purgePackages($rm, $im);
     // initialize composer
     $composer = new Composer();
     $composer->setConfig($config);
     $composer->setPackage($package);
     $composer->setRepositoryManager($rm);
     $composer->setDownloadManager($dm);
     $composer->setInstallationManager($im);
     // init locker if possible
     if (isset($composerFile)) {
         $lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION) ? substr($composerFile, 0, -4) . 'lock' : $composerFile . '.lock';
         $locker = new Package\Locker(new JsonFile($lockFile, new RemoteFilesystem($io)), $rm, md5_file($composerFile));
         $composer->setLocker($locker);
     }
     return $composer;
 }
开发者ID:nlegoff,项目名称:composer,代码行数:65,代码来源:Factory.php


示例11: extract

 protected function extract($file, $path)
 {
     $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
     if (0 === $this->process->execute($command, $ignoredOutput)) {
         return;
     }
     $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
     throw new \RuntimeException($processError);
 }
开发者ID:neon64,项目名称:composer,代码行数:9,代码来源:XzDownloader.php


示例12: extract

 protected function extract($file, $path)
 {
     // we must use cmdline tar, as PharData::extract() messes up symlinks
     $command = 'tar -xzf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
     if (0 === $this->process->execute($command, $ignoredOutput)) {
         return;
     }
     throw new \RuntimeException("Failed to execute '{$command}'\n\n" . $this->process->getErrorOutput());
 }
开发者ID:tam-bourine,项目名称:heroku-buildpack-php,代码行数:9,代码来源:Downloader.php


示例13: testSplitLines

 public function testSplitLines()
 {
     $process = new ProcessExecutor();
     $this->assertEquals(array(), $process->splitLines(''));
     $this->assertEquals(array(), $process->splitLines(null));
     $this->assertEquals(array('foo'), $process->splitLines('foo'));
     $this->assertEquals(array('foo', 'bar'), $process->splitLines("foo\nbar"));
     $this->assertEquals(array('foo', 'bar'), $process->splitLines("foo\r\nbar"));
     $this->assertEquals(array('foo', 'bar'), $process->splitLines("foo\r\nbar\n"));
 }
开发者ID:neon64,项目名称:composer,代码行数:10,代码来源:ProcessExecutorTest.php


示例14: doUpdate

 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
 {
     $url = ProcessExecutor::escape($url);
     $ref = ProcessExecutor::escape($target->getSourceReference());
     $this->io->writeError("    Updating to " . $target->getSourceReference());
     if (!is_dir($path . '/.hg')) {
         throw new \RuntimeException('The .hg directory is missing from ' . $path . ', see http://getcomposer.org/commit-deps for more information');
     }
     $command = sprintf('hg pull %s && hg up %s', $url, $ref);
     if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
         throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
     }
 }
开发者ID:VicDeo,项目名称:poc,代码行数:13,代码来源:HgDownloader.php


示例15: doUpdate

 /**
  * {@inheritDoc}
  */
 public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
 {
     // Ensure we are allowed to use this URL by config
     $this->config->prohibitUrlByConfig($url, $this->io);
     $url = ProcessExecutor::escape($url);
     $ref = ProcessExecutor::escape($target->getSourceReference());
     $this->io->writeError("    Updating to " . $target->getSourceReference());
     if (!$this->hasMetadataRepository($path)) {
         throw new \RuntimeException('The .hg directory is missing from ' . $path . ', see https://getcomposer.org/commit-deps for more information');
     }
     $command = sprintf('hg pull %s && hg up %s', $url, $ref);
     if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
         throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
     }
 }
开发者ID:neon64,项目名称:composer,代码行数:18,代码来源:HgDownloader.php


示例16: execute

 protected function execute($command, array $args, IOInterface $io = null, $workingDirectory = null)
 {
     $processExecutor = new ProcessExecutor($io);
     array_unshift($args, $this->findBinary($command));
     $args = array_map([$processExecutor, 'escape'], $args);
     $outputHandler = function ($type, $data) use($io) {
         if (!$io->isVerbose()) {
             return;
         }
         switch ($type) {
             case Process::ERR:
                 $io->writeError($data);
                 break;
             case Process::OUT:
             default:
                 $io->write($data);
                 break;
         }
     };
     $fullCommand = implode(' ', $args);
     if ($processExecutor->execute($fullCommand, $outputHandler, $workingDirectory) > 0) {
         throw ProcessFailedException::create($command, $fullCommand, $processExecutor->getErrorOutput());
     }
 }
开发者ID:budgeit,项目名称:composer-builder,代码行数:24,代码来源:ExecutorTrait.php


示例17: extract

 protected function extract($file, $path)
 {
     $targetFilepath = $path . DIRECTORY_SEPARATOR . basename(substr($file, 0, -3));
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $command = 'gzip -cd ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
         if (0 === $this->process->execute($command, $ignoredOutput)) {
             return;
         }
         $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
         throw new \RuntimeException($processError);
     }
     $archiveFile = gzopen($file, 'rb');
     $targetFile = fopen($targetFilepath, 'wb');
     while ($string = gzread($archiveFile, 4096)) {
         fwrite($targetFile, $string, strlen($string));
     }
     gzclose($archiveFile);
     fclose($targetFile);
 }
开发者ID:VicDeo,项目名称:poc,代码行数:19,代码来源:GzipDownloader.php


示例18: guessSvnVersion

 private function guessSvnVersion(array $packageConfig, $path)
 {
     SvnUtil::cleanEnv();
     // try to fetch current version from svn
     if (0 === $this->process->execute('svn info --xml', $output, $path)) {
         $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
         $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
         $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
         $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
         if (preg_match($urlPattern, $output, $matches)) {
             if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
                 // we are in a branches path
                 $version = $this->versionParser->normalizeBranch($matches[3]);
                 $prettyVersion = 'dev-' . $matches[3];
                 if ('9999999-dev' === $version) {
                     $version = $prettyVersion;
                 }
                 return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
             }
             $prettyVersion = trim($matches[1]);
             $version = $this->versionParser->normalize($prettyVersion);
             return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
         }
     }
 }
开发者ID:neon64,项目名称:composer,代码行数:25,代码来源:VersionGuesser.php


示例19: executeCommand

 /**
  * Executes a shell command with escaping.
  *
  * @param string $cmd
  * @return bool
  */
 protected function executeCommand($cmd)
 {
     // Shell-escape all arguments except the command.
     $args = func_get_args();
     foreach ($args as $index => $arg) {
         if ($index !== 0) {
             $args[$index] = escapeshellarg($arg);
         }
     }
     // And replace the arguments.
     $command = call_user_func_array('sprintf', $args);
     $output = '';
     if ($this->io->isVerbose()) {
         $this->io->write('<comment>' . $command . '</comment>');
         $io = $this->io;
         $output = function ($type, $data) use($io) {
             if ($type == Process::ERR) {
                 $io->write('<error>' . $data . '</error>');
             } else {
                 $io->write('<comment>' . $data . '</comment>');
             }
         };
     }
     return $this->executor->execute($command, $output) == 0;
 }
开发者ID:pingers,项目名称:composer-patches,代码行数:31,代码来源:Patches.php


示例20: initialize

 /**
  * Initializes path repository.
  *
  * This method will basically read the folder and add the found package.
  */
 protected function initialize()
 {
     parent::initialize();
     foreach ($this->getUrlMatches() as $url) {
         $path = realpath($url) . DIRECTORY_SEPARATOR;
         $composerFilePath = $path . 'composer.json';
         if (!file_exists($composerFilePath)) {
             continue;
         }
         $json = file_get_contents($composerFilePath);
         $package = JsonFile::parseJson($json, $composerFilePath);
         $package['dist'] = array('type' => 'path', 'url' => $url, 'reference' => sha1($json));
         $package['transport-options'] = $this->options;
         if (!isset($package['version'])) {
             $versionData = $this->versionGuesser->guessVersion($package, $path);
             $package['version'] = $versionData['version'] ?: 'dev-master';
         }
         $output = '';
         if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H', $output, $path)) {
             $package['dist']['reference'] = trim($output);
         }
         $package = $this->loader->load($package);
         $this->addPackage($package);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:PathRepository.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Attribute\Type类代码示例发布时间:2022-05-23
下一篇:
PHP Util\Filesystem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap