Overview

Namespaces

  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
    • Tests
      • Batch
      • Cache
      • Common
        • Cache
        • Exception
      • Http
        • Curl
        • Exception
        • Message
          • Header
      • Inflection
      • Iterator
      • Log
      • Message
      • Mock
      • Parser
        • Cookie
        • Message
      • Parsers
        • UriTemplate
      • Plugin
        • Async
        • Backoff
        • Cache
        • Cookie
          • CookieJar
        • CurlAuth
        • ErrorResponse
        • History
        • Log
        • Md5
        • Mock
        • Oauth
        • Redirect
      • Service
        • Builder
        • Command
          • LocationVisitor
            • Request
            • Response
        • Description
        • Exception
        • Mock
          • Command
            • Sub
          • Model
        • Resource
      • Stream
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • VivaPayments
      • Message
  • PHP

Classes

  • AbstractEntityBodyDecorator
  • CachingEntityBody
  • Client
  • EntityBody
  • IoEmittingEntityBody
  • Mimetypes
  • QueryString
  • ReadLimitEntityBody
  • RedirectPlugin
  • StaticClient
  • Url

Interfaces

  • ClientInterface
  • EntityBodyInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class Client

HTTP client

Guzzle\Common\AbstractHasDispatcher implements Guzzle\Common\HasDispatcherInterface
Extended by Guzzle\Http\Client implements Guzzle\Http\ClientInterface

Direct known subclasses

Guzzle\Service\Client

Indirect known subclasses

Guzzle\Tests\Service\Mock\MockClient
Namespace: Guzzle\Http
Located at src/Guzzle/Http/Client.php
Methods summary
public static array
# getAllEvents( )

Get a list of all of the events emitted from the class

Get a list of all of the events emitted from the class

Returns

array

Overrides

Guzzle\Common\AbstractHasDispatcher::getAllEvents()

Implementation of

Guzzle\Common\HasDispatcherInterface::getAllEvents()
public
# __construct( string $baseUrl = '', array|Guzzle\Common\Collection $config = null )

Parameters

$baseUrl
Base URL of the web service
$config
Configuration settings

Throws

RuntimeException
if cURL is not installed
final public Guzzle\Http\Client
# setConfig( array|Guzzle\Common\Collection $config )

Set the configuration object to use with the client

Set the configuration object to use with the client

Parameters

$config
Parameters that define how the client behaves

Returns

Guzzle\Http\Client

Implementation of

Guzzle\Http\ClientInterface::setConfig()
final public mixed|Guzzle\Common\Collection
# getConfig( boolean|string $key = false )

Get a configuration setting or all of the configuration settings. The Collection result of this method can be modified to change the configuration settings of a client.

Get a configuration setting or all of the configuration settings. The Collection result of this method can be modified to change the configuration settings of a client.

A client should honor the following special values:

  • request.options: Associative array of default RequestFactory options to apply to each request
  • request.params: Associative array of request parameters (data values) to apply to each request
  • curl.options: Associative array of cURL configuration settings to apply to each request
  • ssl.certificate_authority: Path a CAINFO, CAPATH, true to use strict defaults, or false to disable verification
  • redirect.disable: Set to true to disable redirects

Parameters

$key

Configuration value to retrieve. Set to FALSE to retrieve all values of the client. The object return can be modified, and modifications will affect the client's config.

Returns

mixed|Guzzle\Common\Collection

See

\Guzzle\Http\Message\RequestFactoryInterface::applyOptions for a full list of request.options options

Implementation of

Guzzle\Http\ClientInterface::getConfig()
public
# setDefaultOption( string $keyOrPath, mixed $value )

Set a default request option on the client that will be used as a default for each request

Set a default request option on the client that will be used as a default for each request

Parameters

$keyOrPath
request.options key (e.g. allow_redirects) or path to a nested key (e.g. headers/foo)
$value
Value to set

Returns


$this
public mixed|null
# getDefaultOption( string $keyOrPath )

Retrieve a default request option from the client

Retrieve a default request option from the client

Parameters

$keyOrPath
request.options key (e.g. allow_redirects) or path to a nested key (e.g. headers/foo)

Returns

mixed|null
final public Guzzle\Http\Client
# setSslVerification( string|boolean $certificateAuthority = true, boolean $verifyPeer = true, integer $verifyHost = 2 )

Set SSL verification options.

Set SSL verification options.

Setting $certificateAuthority to TRUE will result in the bundled cacert.pem being used to verify against the remote host.

Alternate certificates to verify against can be specified with the $certificateAuthority option set to the full path to a certificate file, or the path to a directory containing certificates.

Setting $certificateAuthority to FALSE will turn off peer verification, unset the bundled cacert.pem, and disable host verification. Please don't do this unless you really know what you're doing, and why you're doing it.

Parameters

$certificateAuthority
bool, file path, or directory path
$verifyPeer
FALSE to stop from verifying the peer's certificate.
$verifyHost

Set to 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided.

Returns

Guzzle\Http\Client

Implementation of

Guzzle\Http\ClientInterface::setSslVerification()
public Guzzle\Http\Message\RequestInterface
# createRequest( string $method = 'GET', string|array $uri = null, array|Guzzle\Common\Collection $headers = null, string|resource|array|Guzzle\Http\EntityBodyInterface $body = null, array $options = array() )

Create and return a new Guzzle\Http\Message\RequestInterface configured for the client.

Create and return a new Guzzle\Http\Message\RequestInterface configured for the client.

Use an absolute path to override the base path of the client, or a relative path to append to the base path of the client. The URI can contain the query string as well. Use an array to provide a URI template and additional variables to use in the URI template expansion.

Parameters

$method
HTTP method. Defaults to GET
$uri
Resource URI.
$headers
HTTP headers
$body
Entity body of request (POST/PUT) or response (GET)
$options
Array of options to apply to the request

Returns

Guzzle\Http\Message\RequestInterface

Throws

InvalidArgumentException

if a URI array is passed that does not contain exactly two elements: the URI followed by template variables

Implementation of

Guzzle\Http\ClientInterface::createRequest()
public string|null
# getBaseUrl( boolean $expand = true )

Get the client's base URL as either an expanded or raw URI template

Get the client's base URL as either an expanded or raw URI template

Parameters

$expand
Set to FALSE to get the raw base URL without URI template expansion

Returns

string|null

Implementation of

Guzzle\Http\ClientInterface::getBaseUrl()
public Guzzle\Http\Client
# setBaseUrl( string $url )

Set the base URL of the client

Set the base URL of the client

Parameters

$url
The base service endpoint URL of the webservice

Returns

Guzzle\Http\Client

Implementation of

Guzzle\Http\ClientInterface::setBaseUrl()
public Guzzle\Http\Client
# setUserAgent( string $userAgent, boolean $includeDefault = false )

Set the User-Agent header to be used on all requests from the client

Set the User-Agent header to be used on all requests from the client

Parameters

$userAgent
User agent string
$includeDefault
Set to true to prepend the value to Guzzle's default user agent string

Returns

Guzzle\Http\Client

Implementation of

Guzzle\Http\ClientInterface::setUserAgent()
public string
# getDefaultUserAgent( )

Get the default User-Agent string to use with Guzzle

Get the default User-Agent string to use with Guzzle

Returns

string
public Guzzle\Http\Message\RequestInterface
# get( string|array $uri = null, array|Guzzle\Common\Collection $headers = null, array $options = array() )

Create a GET request for the client

Create a GET request for the client

Parameters

$uri
Resource URI
$headers
HTTP headers
$options

Options to apply to the request. For BC compatibility, you can also pass a string to tell Guzzle to download the body of the response to a particular location. Use the 'body' option instead for forward compatibility.

Returns

Guzzle\Http\Message\RequestInterface

See

Guzzle\Http\ClientInterface::createRequest()

Implementation of

Guzzle\Http\ClientInterface::get()
public Guzzle\Http\Message\RequestInterface
# head( string|array $uri = null, array|Guzzle\Common\Collection $headers = null, array $options = array() )

Create a HEAD request for the client

Create a HEAD request for the client

Parameters

$uri
Resource URI
$headers
HTTP headers
$options
Options to apply to the request

Returns

Guzzle\Http\Message\RequestInterface

See

Guzzle\Http\ClientInterface::createRequest()

Implementation of

Guzzle\Http\ClientInterface::head()
public EntityEnclosingRequestInterface
# delete( string|array $uri = null, array|Guzzle\Common\Collection $headers = null, string|resource|Guzzle\Http\EntityBodyInterface $body = null, array $options = array() )

Create a DELETE request for the client

Create a DELETE request for the client

Parameters

$uri
Resource URI
$headers
HTTP headers
$body
Body to send in the request
$options
Options to apply to the request

Returns

EntityEnclosingRequestInterface

See

Guzzle\Http\ClientInterface::createRequest()

Implementation of

Guzzle\Http\ClientInterface::delete()
public EntityEnclosingRequestInterface
# put( string|array $uri = null, array|Guzzle\Common\Collection $headers = null, string|resource|Guzzle\Http\EntityBodyInterface $body = null, array $options = array() )

Create a PUT request for the client

Create a PUT request for the client

Parameters

$uri
Resource URI
$headers
HTTP headers
$body
Body to send in the request
$options
Options to apply to the request

Returns

EntityEnclosingRequestInterface

See

Guzzle\Http\ClientInterface::createRequest()

Implementation of

Guzzle\Http\ClientInterface::put()
public EntityEnclosingRequestInterface
# patch( string|array $uri = null, array|Guzzle\Common\Collection $headers = null, string|resource|Guzzle\Http\EntityBodyInterface $body = null, array $options = array() )

Create a PATCH request for the client

Create a PATCH request for the client

Parameters

$uri
Resource URI
$headers
HTTP headers
$body
Body to send in the request
$options
Options to apply to the request

Returns

EntityEnclosingRequestInterface

See

Guzzle\Http\ClientInterface::createRequest()

Implementation of

Guzzle\Http\ClientInterface::patch()
public EntityEnclosingRequestInterface
# post( string|array $uri = null, array|Guzzle\Common\Collection $headers = null, array|Guzzle\Common\Collection|string|Guzzle\Http\EntityBodyInterface $postBody = null, array $options = array() )

Create a POST request for the client

Create a POST request for the client

Parameters

$uri
Resource URI
$headers
HTTP headers
$postBody

POST body. Can be a string, EntityBody, or associative array of POST fields to send in the body of the request. Prefix a value in the array with the @ symbol to reference a file.

$options
Options to apply to the request

Returns

EntityEnclosingRequestInterface

See

Guzzle\Http\ClientInterface::createRequest()

Implementation of

Guzzle\Http\ClientInterface::post()
public Guzzle\Http\Message\RequestInterface
# options( string|array $uri = null, array $options = array() )

Create an OPTIONS request for the client

Create an OPTIONS request for the client

Parameters

$uri
Resource URI
$options
Options to apply to the request

Returns

Guzzle\Http\Message\RequestInterface

See

Guzzle\Http\ClientInterface::createRequest()

Implementation of

Guzzle\Http\ClientInterface::options()
public Guzzle\Http\Message\Response|array
# send( array|Guzzle\Http\Message\RequestInterface $requests )

Sends a single request or an array of requests in parallel

Sends a single request or an array of requests in parallel

Parameters

$requests
One or more RequestInterface objects to send

Returns

Guzzle\Http\Message\Response|array
Returns a single Response or an array of Response objects

Implementation of

Guzzle\Http\ClientInterface::send()
public Guzzle\Http\Client
# setCurlMulti( Guzzle\Http\Curl\CurlMultiInterface $curlMulti )

Set a curl multi object to be used internally by the client for transferring requests.

Set a curl multi object to be used internally by the client for transferring requests.

Parameters

$curlMulti
Multi object

Returns

Guzzle\Http\Client
public Guzzle\Http\Curl\CurlMultiInterface|Guzzle\Http\Curl\CurlMultiProxy
# getCurlMulti( )

Returns

Guzzle\Http\Curl\CurlMultiInterface|Guzzle\Http\Curl\CurlMultiProxy
public
# setRequestFactory( Guzzle\Http\Message\RequestFactoryInterface $factory )
public Guzzle\Http\Client
# setUriTemplate( Guzzle\Parser\UriTemplate\UriTemplateInterface $uriTemplate )

Set the URI template expander to use with the client

Set the URI template expander to use with the client

Parameters

$uriTemplate
URI template expander

Returns

Guzzle\Http\Client
protected string
# expandTemplate( string $template, array $variables = null )

Expand a URI template while merging client config settings into the template variables

Expand a URI template while merging client config settings into the template variables

Parameters

$template
Template to expand
$variables
Variables to inject

Returns

string
protected Guzzle\Parser\UriTemplate\UriTemplateInterface
# getUriTemplate( )

Get the URI template expander used by the client

Get the URI template expander used by the client

Returns

Guzzle\Parser\UriTemplate\UriTemplateInterface
protected array
# sendMultiple( array $requests )

Send multiple requests in parallel

Send multiple requests in parallel

Parameters

$requests
Array of RequestInterface objects

Returns

array
Returns an array of Response objects
protected Guzzle\Http\Message\RequestInterface
# prepareRequest( Guzzle\Http\Message\RequestInterface $request, array $options = array() )

Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.

Prepare a request to be sent from the Client by adding client specific behaviors and properties to the request.

Parameters

$request
Request to prepare for the client
$options
Options to apply to the request

Returns

Guzzle\Http\Message\RequestInterface
protected
# initSsl( )

Initializes SSL settings

Initializes SSL settings

public
# getDefaultHeaders( )

Deprecated

public
# setDefaultHeaders( $headers )

Deprecated

public
# preparePharCacert( $md5Check = true )

Deprecated

public static string
# extractPharCacert( string $pharCacertPath )

Copies the phar cacert from a phar into the temp directory.

Copies the phar cacert from a phar into the temp directory.

Parameters

$pharCacertPath

Path to the phar cacert. For example: 'phar://aws.phar/Guzzle/Http/Resources/cacert.pem'

Returns

string
Returns the path to the extracted cacert file.

Throws

RuntimeException

Throws if the phar cacert cannot be found or the file cannot be copied to the temp dir.

Methods inherited from Guzzle\Common\AbstractHasDispatcher
addSubscriber(), dispatch(), getEventDispatcher(), setEventDispatcher()
Constants summary
string REQUEST_PARAMS

Deprecated

Use [request.options][params]
# 'request.params'
string REQUEST_OPTIONS
# 'request.options'
string CURL_OPTIONS
# 'curl.options'
string SSL_CERT_AUTHORITY
# 'ssl.certificate_authority'
string DISABLE_REDIRECTS
# RedirectPlugin::DISABLE
float DEFAULT_SELECT_TIMEOUT
# 1.0
integer MAX_HANDLES
# 3
Constants inherited from Guzzle\Http\ClientInterface
CREATE_REQUEST, HTTP_DATE
Properties summary
protected Guzzle\Common\Collection $defaultHeaders

Default HTTP headers to set on each request

Default HTTP headers to set on each request

#
protected string $userAgent

The user agent string to set on each request

The user agent string to set on each request

#
protected Guzzle\Http\Message\RequestFactoryInterface $requestFactory

Request factory used by the client

Request factory used by the client

#
Properties inherited from Guzzle\Common\AbstractHasDispatcher
$eventDispatcher
Omnipay Viva Payments Gateway Module API Documentation API documentation generated by ApiGen