/**
  * @inheritdoc
  */
 public function register(Application $app)
 {
     if (!isset($app['guzzle.base_url'])) {
         $app['guzzle.base_url'] = '/';
     }
     if (!isset($app['guzzle.handler'])) {
         $app['guzzle.handler'] = Utils::getDefaultHandler();
     }
     if (!isset($app['guzzle.message_factory'])) {
         $app['guzzle.message_factory'] = new MessageFactory();
     }
     if (!isset($app['guzzle.defaults'])) {
         $app['guzzle.defaults'] = [];
     }
     if (!isset($app['guzzle.emitter'])) {
         $app['guzzle.emitter'] = new Emitter();
     }
     $app['guzzle.client'] = function ($app) {
         return new Client(array('base_url' => $app['guzzle.base_url'], 'message_factory' => $app['guzzle.message_factory'], 'defaults' => $app['guzzle.defaults'], 'emitter' => $app['guzzle.emitter']));
     };
 }
 /**
  * Returns the Guzzle client configured according to the system environment
  * (e.g. it takes into account whether it should use a proxy server or not).
  *
  * @return Client The configured Guzzle client
  *
  * @throws \RuntimeException If the php-curl is not installed or the allow_url_fopen ini setting is not set
  */
 protected function getGuzzleClient()
 {
     $defaults = array();
     // check if the client must use a proxy server
     if (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy'])) {
         $defaults['proxy'] = !empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY'];
     }
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
         $defaults['debug'] = true;
     }
     try {
         $handler = Utils::getDefaultHandler();
     } catch (\RuntimeException $e) {
         throw new \RuntimeException('The Symfony installer requires the php-curl extension or the allow_url_fopen ini setting.');
     }
     return new Client(array('defaults' => $defaults, 'handler' => $handler));
 }
Example #3
0
 /**
  * @deprecated Use GuzzleHttp\Utils::getDefaultHandler
  */
 public static function getDefaultHandler()
 {
     return Utils::getDefaultHandler();
 }