library/Service/HttpClientServiceFactory.php
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');

        $client = new Client();
        if (!empty($config[$this->configKey])) {

            $clientOptions = $config[$this->configKey];

            if (isset($clientOptions['uri'])) {
                $client->setUri($clientOptions['uri']);
                unset($clientOptions['uri']);
            }

            if (isset($clientOptions['auth'])) {
                $auth = $clientOptions['auth'];
                $client->setAuth(
                    isset($auth['user'])     ? $auth['user']     : '',
                    isset($auth['password']) ? $auth['password'] : '',
                    isset($auth['type'])     ? $auth['type']     : $client::AUTH_BASIC
                );
                unset($clientOptions['auth']);
            }

            $client->setOptions($config[$this->configKey]);
        }

        return $client;
    }
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');

        $client = new Client();
        if (!empty($config[$this->configKey])) {

            $clientOptions = $config[$this->configKey];

            if (isset($clientOptions['uri'])) {
                $client->setUri($clientOptions['uri']);
                unset($clientOptions['uri']);
            }

            if (isset($clientOptions['auth'])) {
                $auth = $clientOptions['auth'];
                $client->setAuth(
                    isset($auth['user'])     ? $auth['user']     : '',
                    isset($auth['password']) ? $auth['password'] : '',
                    isset($auth['type'])     ? $auth['type']     : $client::AUTH_BASIC
                );
                unset($clientOptions['auth']);
            }

            $client->setOptions($config[$this->configKey]);
        }

        return $client;
    }
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Config' ) ; $ client = new Client ( ) ; if ( ! empty ( $ config [ $ this -> configKey ] ) ) { $ clientOptions = $ config [ $ this -> configKey ] ; if ( isset ( $ clientOptions [ 'uri' ] ) ) { $ client -> setUri ( $ clientOptions [ 'uri' ] ) ; unset ( $ clientOptions [ 'uri' ] ) ; } if ( isset ( $ clientOptions [ 'auth' ] ) ) { $ auth = $ clientOptions [ 'auth' ] ; $ client -> setAuth ( isset ( $ auth [ 'user' ] ) ? $ auth [ 'user' ] : '' , isset ( $ auth [ 'password' ] ) ? $ auth [ 'password' ] : '' , isset ( $ auth [ 'type' ] ) ? $ auth [ 'type' ] : $ client :: AUTH_BASIC ) ; unset ( $ clientOptions [ 'auth' ] ) ; } $ client -> setOptions ( $ config [ $ this -> configKey ] ) ; } return $ client ; }
Create a http client service

@param ServiceLocatorInterface $serviceLocator
@return Client
Create a http client service