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


PHP ProcessExecutor::setTimeout方法代码示例

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


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

示例1: 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

示例2: testTimeout

 public function testTimeout()
 {
     ProcessExecutor::setTimeout(1);
     $process = new ProcessExecutor();
     $this->assertEquals(1, $process->getTimeout());
     ProcessExecutor::setTimeout(60);
 }
开发者ID:neon64,项目名称:composer,代码行数:7,代码来源:ProcessExecutorTest.php

示例3: 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

示例4: 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

示例5: createComposer

 /**
  * Creates a Composer instance
  *
  * @param IOInterface       $io          IO instance
  * @param array|string|null $localConfig either a configuration array or a filename to read from, if null it will
  *                                       read from the default filename
  * @throws \InvalidArgumentException
  * @return Composer
  */
 public function createComposer(IOInterface $io, $localConfig = null)
 {
     // load Composer configuration
     if (null === $localConfig) {
         $localConfig = static::getComposerFile();
     }
     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 = static::createConfig();
     $config->merge($localConfig);
     // 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 . '"');
             }
             $io->setAuthentication($domain, $token, 'x-oauth-basic');
         }
     }
     $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 local repository
     $this->addLocalRepository($rm, $vendorDir);
     // load package
     $loader = new Package\Loader\RootPackageLoader($rm, $config);
     $package = $loader->load($localConfig);
     // initialize download manager
     $dm = $this->createDownloadManager($io, $config);
     // initialize installation manager
     $im = $this->createInstallationManager();
     // initialize composer
     $composer = new Composer();
     $composer->setConfig($config);
     $composer->setPackage($package);
     $composer->setRepositoryManager($rm);
     $composer->setDownloadManager($dm);
     $composer->setInstallationManager($im);
     // initialize event dispatcher
     $dispatcher = new EventDispatcher($composer, $io);
     $composer->setEventDispatcher($dispatcher);
     // initialize autoload generator
     $generator = new AutoloadGenerator($dispatcher);
     $composer->setAutoloadGenerator($generator);
     // add installers to the manager
     $this->createDefaultInstallers($im, $composer, $io);
     // purge packages if they have been deleted on the filesystem
     $this->purgePackages($rm, $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, $im, md5_file($composerFile));
         $composer->setLocker($locker);
     }
     return $composer;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:82,代码来源:Factory.php

示例6: createComposer

 /**
  * Creates a Composer instance
  *
  * @param  IOInterface               $io             IO instance
  * @param  array|string|null         $localConfig    either a configuration array or a filename to read from, if null it will
  *                                                   read from the default filename
  * @param  bool                      $disablePlugins Whether plugins should not be loaded
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  * @return Composer
  */
 public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false)
 {
     // load Composer configuration
     if (null === $localConfig) {
         $localConfig = static::getComposerFile();
     }
     if (is_string($localConfig)) {
         $composerFile = $localConfig;
         $file = new JsonFile($localConfig, new RemoteFilesystem($io));
         if (!$file->exists()) {
             if ($localConfig === './composer.json' || $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();
     }
     // Load config and override with local config/auth config
     $config = static::createConfig($io);
     $config->merge($localConfig);
     if (isset($composerFile)) {
         if ($io && $io->isDebug()) {
             $io->write('Loading config file ' . $composerFile);
         }
         $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json');
         if ($localAuthFile->exists()) {
             if ($io && $io->isDebug()) {
                 $io->write('Loading config file ' . $localAuthFile->getPath());
             }
             $config->merge(array('config' => $localAuthFile->read()));
             $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
         }
     }
     // load auth configs into the IO instance
     $io->loadConfiguration($config);
     $vendorDir = $config->get('vendor-dir');
     $binDir = $config->get('bin-dir');
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
     // initialize composer
     $composer = new Composer();
     $composer->setConfig($config);
     // initialize event dispatcher
     $dispatcher = new EventDispatcher($composer, $io);
     // initialize repository manager
     $rm = $this->createRepositoryManager($io, $config, $dispatcher);
     // load local repository
     $this->addLocalRepository($rm, $vendorDir);
     // load package
     $parser = new VersionParser();
     $loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, new ProcessExecutor($io));
     $package = $loader->load($localConfig);
     // initialize installation manager
     $im = $this->createInstallationManager();
     // Composer composition
     $composer->setPackage($package);
     $composer->setRepositoryManager($rm);
     $composer->setInstallationManager($im);
     // initialize download manager
     $dm = $this->createDownloadManager($io, $config, $dispatcher);
     $composer->setDownloadManager($dm);
     $composer->setEventDispatcher($dispatcher);
     // initialize autoload generator
     $generator = new AutoloadGenerator($dispatcher, $io);
     $composer->setAutoloadGenerator($generator);
     // add installers to the manager
     $this->createDefaultInstallers($im, $composer, $io);
     $globalRepository = $this->createGlobalRepository($config, $vendorDir);
     $pm = $this->createPluginManager($composer, $io, $globalRepository);
     $composer->setPluginManager($pm);
     if (!$disablePlugins) {
         $pm->loadInstalledPlugins();
     }
     // purge packages if they have been deleted on the filesystem
     $this->purgePackages($rm, $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($io, new JsonFile($lockFile, new RemoteFilesystem($io, $config)), $rm, $im, md5_file($composerFile));
         $composer->setLocker($locker);
     }
     return $composer;
 }
开发者ID:VSeryi,项目名称:TechnicSolder,代码行数:98,代码来源:Factory.php

示例7: createComposer

 /**
  * Creates a Composer instance
  *
  * @return Composer
  */
 public function createComposer(IOInterface $io, $composerFile = null)
 {
     // load Composer configuration
     if (null === $composerFile) {
         $composerFile = getenv('COMPOSER') ?: 'composer.json';
     }
     $file = new JsonFile($composerFile);
     if (!$file->exists()) {
         if ($composerFile === 'composer.json') {
             $message = 'Composer could not find a composer.json file in ' . getcwd();
         } else {
             $message = 'Composer could not find the config file: ' . $composerFile;
         }
         $instructions = 'To initialize a project, please create a composer.json file as described on the http://packagist.org/ "Getting Started" section';
         throw new \InvalidArgumentException($message . PHP_EOL . $instructions);
     }
     // Configuration defaults
     $composerConfig = array('vendor-dir' => 'vendor', 'process-timeout' => 300);
     $packageConfig = $file->read();
     if (isset($packageConfig['config']) && is_array($packageConfig['config'])) {
         $packageConfig['config'] = array_merge($composerConfig, $packageConfig['config']);
     } else {
         $packageConfig['config'] = $composerConfig;
     }
     $vendorDir = getenv('COMPOSER_VENDOR_DIR') ?: $packageConfig['config']['vendor-dir'];
     if (!isset($packageConfig['config']['bin-dir'])) {
         $packageConfig['config']['bin-dir'] = $vendorDir . '/bin';
     }
     $binDir = getenv('COMPOSER_BIN_DIR') ?: $packageConfig['config']['bin-dir'];
     // setup process timeout
     $processTimeout = getenv('COMPOSER_PROCESS_TIMEOUT') ?: $packageConfig['config']['process-timeout'];
     ProcessExecutor::setTimeout((int) $processTimeout);
     // initialize repository manager
     $rm = $this->createRepositoryManager($io);
     // load default repository unless it's explicitly disabled
     $loadPackagist = true;
     if (isset($packageConfig['repositories'])) {
         foreach ($packageConfig['repositories'] as $repo) {
             if (isset($repo['packagist']) && $repo['packagist'] === false) {
                 $loadPackagist = false;
             }
         }
     }
     if ($loadPackagist) {
         $this->addPackagistRepository($rm);
     }
     // load local repository
     $this->addLocalRepository($rm, $vendorDir);
     // load package
     $loader = new Package\Loader\RootPackageLoader($rm);
     $package = $loader->load($packageConfig);
     // initialize download manager
     $dm = $this->createDownloadManager($io);
     // initialize installation manager
     $im = $this->createInstallationManager($rm, $dm, $vendorDir, $binDir, $io);
     // init locker
     $lockFile = substr($composerFile, -5) === '.json' ? substr($composerFile, 0, -4) . 'lock' : $composerFile . '.lock';
     $locker = new Package\Locker(new JsonFile($lockFile), $rm, md5_file($composerFile));
     // initialize composer
     $composer = new Composer();
     $composer->setPackage($package);
     $composer->setLocker($locker);
     $composer->setRepositoryManager($rm);
     $composer->setDownloadManager($dm);
     $composer->setInstallationManager($im);
     return $composer;
 }
开发者ID:roadrunner,项目名称:composer,代码行数:72,代码来源:Factory.php

示例8: createComposer

 public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false)
 {
     if (null === $localConfig) {
         $localConfig = static::getComposerFile();
     }
     if (is_string($localConfig)) {
         $composerFile = $localConfig;
         $file = new JsonFile($localConfig, new RemoteFilesystem($io));
         if (!$file->exists()) {
             if ($localConfig === './composer.json' || $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();
     }
     $config = static::createConfig();
     $config->merge($localConfig);
     $io->loadConfiguration($config);
     $vendorDir = $config->get('vendor-dir');
     $binDir = $config->get('bin-dir');
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
     $composer = new Composer();
     $composer->setConfig($config);
     $dispatcher = new EventDispatcher($composer, $io);
     $rm = $this->createRepositoryManager($io, $config, $dispatcher);
     $this->addLocalRepository($rm, $vendorDir);
     $parser = new VersionParser();
     $loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, new ProcessExecutor($io));
     $package = $loader->load($localConfig);
     $im = $this->createInstallationManager();
     $composer->setPackage($package);
     $composer->setRepositoryManager($rm);
     $composer->setInstallationManager($im);
     $dm = $this->createDownloadManager($io, $config, $dispatcher);
     $composer->setDownloadManager($dm);
     $composer->setEventDispatcher($dispatcher);
     $generator = new AutoloadGenerator($dispatcher);
     $composer->setAutoloadGenerator($generator);
     $this->createDefaultInstallers($im, $composer, $io);
     $globalRepository = $this->createGlobalRepository($config, $vendorDir);
     $pm = $this->createPluginManager($composer, $io, $globalRepository);
     $composer->setPluginManager($pm);
     if (!$disablePlugins) {
         $pm->loadInstalledPlugins();
     }
     $this->purgePackages($rm, $im);
     if (isset($composerFile)) {
         $lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION) ? substr($composerFile, 0, -4) . 'lock' : $composerFile . '.lock';
         $locker = new Package\Locker($io, new JsonFile($lockFile, new RemoteFilesystem($io)), $rm, $im, md5_file($composerFile));
         $composer->setLocker($locker);
     }
     return $composer;
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:58,代码来源:Factory.php

示例9: loadConfiguration

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

示例10: loadConfiguration

 /**
  * {@inheritDoc}
  */
 public function loadConfiguration(Config $config)
 {
     $githubOauth = $config->get('github-oauth');
     $gitlabOauth = $config->get('gitlab-oauth');
     $httpBasic = $config->get('http-basic');
     // Use COMPOSER_AUTH environment variable if set
     if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
         $authData = json_decode($composerAuthEnv, true);
         if (is_null($authData)) {
             throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed');
         }
         if (isset($authData['github-oauth'])) {
             $githubOauth = array_merge($githubOauth, $authData['github-oauth']);
         }
         if (isset($authData['gitlab-oauth'])) {
             $gitlabOauth = array_merge($gitlabOauth, $authData['gitlab-oauth']);
         }
         if (isset($authData['http-basic'])) {
             $httpBasic = array_merge($httpBasic, $authData['http-basic']);
         }
     }
     // reload oauth token from config if available
     if ($githubOauth) {
         foreach ($githubOauth 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 ($gitlabOauth) {
         foreach ($gitlabOauth as $domain => $token) {
             $this->setAuthentication($domain, $token, 'oauth2');
         }
     }
     // reload http basic credentials from config if available
     if ($httpBasic) {
         foreach ($httpBasic as $domain => $cred) {
             $this->setAuthentication($domain, $cred['username'], $cred['password']);
         }
     }
     // setup process timeout
     ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
 }
开发者ID:Sernor,项目名称:composer,代码行数:47,代码来源:BaseIO.php


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