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


PHP IOInterface::overwrite方法代码示例

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


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

示例1: referencePackages

 public function referencePackages(PackageSet $packageSet, IOInterface $io, $apiUrl = null)
 {
     if (!$apiUrl) {
         $apiUrl = 'https://php-bach.org';
     }
     $apiUrlFormat = $apiUrl . '/p/%s.json';
     //cURL
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HEADER, true);
     /** @var Package $package */
     foreach ($packageSet as $package) {
         $packageName = $package->getPackageName();
         $versionName = $package->getVersion();
         $url = sprintf($apiUrlFormat, $packageName);
         curl_setopt($ch, CURLOPT_URL, $url);
         $response = curl_exec($ch);
         $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         $message = '<info>Checking:</info> ' . $packageName . ' (' . $versionName . ') ...';
         $io->write($message);
         if ('200' === (string) $code) {
             $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
             // ヘッダサイズ取得
             $body = substr($response, $header_size);
             // bodyだけ切り出し
             if ($this->parseResponse($package, $body)) {
                 $io->overwrite('<info>Done.</info>');
             } else {
                 $io->overwrite('<fg=white;bg=magenta>Version not found.</>');
             }
         } elseif ('404' === (string) $code) {
             $io->overwrite('<fg=white;bg=magenta>Package not found.</>');
         } else {
             $io->overwriteError($message . '<error>Connection error.</error>');
         }
     }
     curl_close($ch);
 }
开发者ID:tisayama,项目名称:composer-vuln-handler,代码行数:38,代码来源:Reference.php

示例2: download

 /**
  * @param string $url      URL of the archive on Amazon S3.
  * @param bool   $progress Show progress
  * @param string $to       Target file name
  *
  * @throws \Composer\Downloader\TransportException
  */
 public function download($url, $progress, $to = null)
 {
     list($bucket, $key) = $this->determineBucketAndKey($url);
     if ($progress) {
         $this->io->write("    Downloading: <comment>connection...</comment>", false);
     }
     try {
         $params = array('Bucket' => $bucket, 'Key' => $key);
         if ($to) {
             $params['command.response_body'] = \Guzzle\Http\EntityBody::factory(fopen($to, 'w+'));
         }
         $s3 = self::s3factory($this->config);
         $result = $s3->getObject($params);
         if ($progress) {
             $this->io->overwrite("    Downloading: <comment>100%</comment>");
         }
         if ($to) {
             if (false === file_exists($to) || !filesize($to)) {
                 $errorMessage = sprintf("Unknown error occurred: '%s' was not downloaded from '%s'.", $key, $url);
                 throw new TransportException($errorMessage);
             }
         } else {
             return $result['Body'];
         }
     } catch (\Aws\Common\Exception\InstanceProfileCredentialsException $e) {
         $msg = "Please add key/secret into config.json or set up an IAM profile for your EC2 instance.";
         throw new TransportException($msg, 403, $e);
     } catch (Aws\S3\Exception\S3Exception $e) {
         throw new TransportException("Connection to Amazon S3 failed.", null, $e);
     } catch (TransportException $e) {
         throw $e;
         // just re-throw
     } catch (\Exception $e) {
         throw new TransportException("Problem?", null, $e);
     }
     return $this;
 }
开发者ID:fabdsp,项目名称:composer-aws,代码行数:44,代码来源:AwsClient.php

示例3: load

 /**
  * {@inheritDoc}
  */
 public function load(LazyPackageInterface $package)
 {
     if (isset($this->cache[$package->getUniqueName()])) {
         return $this->cache[$package->getUniqueName()];
     }
     $this->validateConfig();
     $filename = $this->assetType->getFilename();
     $msg = 'Reading ' . $filename . ' of <info>' . $package->getName() . '</info> (<comment>' . $package->getPrettyVersion() . '</comment>)';
     if ($this->verbose) {
         $this->io->write($msg);
     } else {
         $this->io->overwrite($msg, false);
     }
     $realPackage = $this->loadRealPackage($package);
     $this->cache[$package->getUniqueName()] = $realPackage;
     if (!$this->verbose) {
         $this->io->overwrite('', false);
     }
     return $realPackage;
 }
开发者ID:cychenyin,项目名称:postmill,代码行数:23,代码来源:LazyAssetPackageLoader.php

示例4: promptAuth

 public function promptAuth(HttpGetResponse $res, CConfig $config, IO\IOInterface $io)
 {
     $httpCode = $res->info['http_code'];
     // 404s are only handled for github
     if (404 === $httpCode) {
         return false;
     }
     // fail if the console is not interactive
     if (!$io->isInteractive()) {
         switch ($httpCode) {
             case 401:
                 $message = "The '{$this->getURL()}' URL required authentication.\nYou must be using the interactive console to authenticate";
                 break;
             case 403:
                 $message = "The '{$this->getURL()}' URL could not be accessed.";
                 break;
         }
         throw new Downloader\TransportException($message, $httpCode);
     }
     // fail if we already have auth
     if ($io->hasAuthentication($this->origin)) {
         throw new Downloader\TransportException("Invalid credentials for '{$this->getURL()}', aborting.", $httpCode);
     }
     $io->overwrite("    Authentication required (<info>{$this->host}</info>):");
     $username = $io->ask('      Username: ');
     $password = $io->askAndHideAnswer('      Password: ');
     $io->setAuthentication($this->origin, $username, $password);
     return true;
 }
开发者ID:k0pernikus,项目名称:prestissimo,代码行数:29,代码来源:HttpGetRequest.php

示例5: runTask

 /**
  * @param string $message
  * @param callable $task
  */
 private static function runTask($message, callable $task)
 {
     self::$io->write(sprintf('<info> - [ ] %s</info>', $message), false);
     $task();
     self::$io->overwrite(sprintf('<info> - [x] %s</info>', $message), true);
 }
开发者ID:php-school,项目名称:workshop-starter-kit,代码行数:10,代码来源:Creator.php


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