Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Public Member Functions | |
__construct (array $config=[]) | |
Clients accept an array of constructor parameters. | |
__call ($method, $args) | |
getConfig (?string $option=null) | |
Get a client configuration option. | |
request (string $method, $uri='', array $options=[]) | |
Create and send an HTTP request. | |
requestAsync (string $method, $uri='', array $options=[]) | |
Create and send an asynchronous HTTP request. | |
send (RequestInterface $request, array $options=[]) | |
Send an HTTP request. | |
sendAsync (RequestInterface $request, array $options=[]) | |
Asynchronously send an HTTP request. | |
sendRequest (RequestInterface $request) | |
The HttpClient PSR (PSR-18) specify this method. | |
Public Attributes | |
const | MAJOR_VERSION = 7 |
The Guzzle major version. | |
GuzzleHttp\Client::__construct | ( | array | $config = [] | ) |
Clients accept an array of constructor parameters.
Here's an example of creating a client using a base_uri and an array of default request options to apply to each request:
$client = new Client([ 'base_uri' => 'http://www.foo.com/1.0/', 'timeout' => 0, 'allow_redirects' => false, 'proxy' => '192.168.16.1:10' ]);
Client configuration settings include the following options:
array | $config | Client configuration settings. |
Reimplemented in core\http_client.
GuzzleHttp\Client::__call | ( | $method, | |
$args ) |
string | $method | |
array | $args |
PromiseInterface|ResponseInterface |
GuzzleHttp\Client::getConfig | ( | ?string | $option = null | ) |
Get a client configuration option.
These options include default request options of the client, a "handler" (if utilized by the concrete client), and a "base_uri" if utilized by the concrete client.
string | null | $option | The config option to retrieve. |
mixed |
Implements GuzzleHttp\ClientInterface.
GuzzleHttp\Client::request | ( | string | $method, |
$uri = '', | |||
array | $options = [] ) |
Create and send an HTTP request.
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 URL can contain the query string as well.
string | $method | HTTP method. |
string | UriInterface | $uri | URI object or string. |
array | $options | Request options to apply. See GuzzleHttp\RequestOptions. |
GuzzleException |
Implements GuzzleHttp\ClientInterface.
GuzzleHttp\Client::requestAsync | ( | string | $method, |
$uri = '', | |||
array | $options = [] ) |
Create and send an asynchronous HTTP request.
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 URL can contain the query string as well. Use an array to provide a URL template and additional variables to use in the URL template expansion.
string | $method | HTTP method |
string | UriInterface | $uri | URI object or string. |
array | $options | Request options to apply. See GuzzleHttp\RequestOptions. |
Implements GuzzleHttp\ClientInterface.
GuzzleHttp\Client::send | ( | RequestInterface | $request, |
array | $options = [] ) |
Send an HTTP request.
array | $options | Request options to apply to the given request and to the transfer. See GuzzleHttp\RequestOptions. |
GuzzleException |
Implements GuzzleHttp\ClientInterface.
GuzzleHttp\Client::sendAsync | ( | RequestInterface | $request, |
array | $options = [] ) |
Asynchronously send an HTTP request.
array | $options | Request options to apply to the given request and to the transfer. See GuzzleHttp\RequestOptions. |
Implements GuzzleHttp\ClientInterface.
GuzzleHttp\Client::sendRequest | ( | RequestInterface | $request | ) |
The HttpClient PSR (PSR-18) specify this method.
@inheritDoc
Implements Psr\Http\Client\ClientInterface.