Curl
extends AbstractClient
in package
HTTP curl client class
Tags
Table of Contents
- $method : string
- Method
- $options : array<string|int, mixed>
- cURL options
- $request : Request
- Client request object
- $resource : resource
- Client resource object
- $response : Response
- Client response object
- $url : string
- URL
- __construct() : mixed
- Constructor
- addRequestHeader() : AbstractClient
- Add request header
- addRequestHeaders() : AbstractClient
- Add request headers
- addResponseHeader() : AbstractClient
- Add response header
- addResponseHeaders() : AbstractClient
- Add response headers
- createAsJson() : AbstractClient
- Create request as JSON
- createMultipartForm() : AbstractClient
- Create request as a multipart form
- createUrlEncodedForm() : AbstractClient
- Create request as a URL-encoded form
- curl() : resource
- Return cURL resource (alias to $this->getResource())
- disconnect() : void
- Close the cURL connection
- getField() : mixed
- Get a field
- getFields() : array<string|int, mixed>
- Get all field
- getInfo() : array<string|int, mixed>|string
- Return the cURL session last info
- getMethod() : string
- Get the method
- getOption() : string
- Get a cURL session option
- getParsedResponse() : mixed
- Get the parsed response
- getRequest() : Request
- Get the request object
- getRequestBody() : string
- Get the request body
- getRequestHeader() : mixed
- Get the request header
- getRequestHeaders() : array<string|int, mixed>
- Get the request headers
- getResource() : resource
- Get the resource
- getResponse() : Response
- Get the response object
- getResponseBody() : string
- Get the response body
- getResponseCode() : string
- Get the response code
- getResponseHeader() : mixed
- Get the response header
- getResponseHeaders() : array<string|int, mixed>
- Get the response headers
- getUrl() : string
- Get the URL
- hasOption() : bool
- Has a cURL session option
- hasRequest() : bool
- Has request object
- hasRequestHeader() : bool
- Has request header
- hasRequestHeaders() : bool
- Has request headers
- hasResource() : bool
- Determine whether or not resource is available
- hasResponse() : bool
- Has response object
- hasResponseHeader() : bool
- Has response header
- hasResponseHeaders() : bool
- Has response headers
- isJson() : bool
- Check if request is JSON
- isMultipartForm() : bool
- Check if request is a multipart form
- isReturnHeader() : bool
- Check if cURL is set to return header
- isReturnTransfer() : bool
- Check if cURL is set to return transfer
- isUrlEncodedForm() : bool
- Check if request is a URL-encoded form
- open() : Curl
- Create and open cURL resource
- removeField() : AbstractClient
- Remove a field
- removeFields() : AbstractClient
- Remove all fields
- request() : Request
- Get the request object (alias method)
- resource() : resource
- Get the resource (alias method)
- response() : Response
- Get the response object (alias method)
- send() : void
- Method to send the request and get the response
- setField() : AbstractClient
- Set a field
- setFields() : AbstractClient
- Set all fields
- setMethod() : Curl
- Set the method
- setOption() : Curl
- Set cURL session option
- setOptions() : Curl
- Set cURL session options
- setRequest() : AbstractClient
- Set the request object
- setResponse() : AbstractClient
- Set the response object
- setReturnHeader() : Curl
- Set cURL option to return the header
- setReturnTransfer() : Curl
- Set cURL option to return the transfer
- setUrl() : AbstractClient
- Set the URL
- throwError() : void
- Throw an exception upon an error.
- version() : array<string|int, mixed>
- Return the cURL version
Properties
$method
Method
protected
string
$method
= null
$options
cURL options
protected
array<string|int, mixed>
$options
= []
$request
Client request object
protected
Request
$request
= null
$resource
Client resource object
protected
resource
$resource
= null
$response
Client response object
protected
Response
$response
= null
$url
URL
protected
string
$url
= null
Methods
__construct()
Constructor
public
__construct([string $url = null ][, string $method = 'GET' ][, array<string|int, mixed> $opts = null ]) : mixed
Instantiate the cURL object
Parameters
- $url : string = null
- $method : string = 'GET'
- $opts : array<string|int, mixed> = null
Tags
Return values
mixed —addRequestHeader()
Add request header
public
addRequestHeader(string $name, string $value) : AbstractClient
Parameters
- $name : string
- $value : string
Return values
AbstractClient —addRequestHeaders()
Add request headers
public
addRequestHeaders(array<string|int, mixed> $headers) : AbstractClient
Parameters
- $headers : array<string|int, mixed>
Return values
AbstractClient —addResponseHeader()
Add response header
public
addResponseHeader(string $name, string $value) : AbstractClient
Parameters
- $name : string
- $value : string
Return values
AbstractClient —addResponseHeaders()
Add response headers
public
addResponseHeaders(array<string|int, mixed> $headers) : AbstractClient
Parameters
- $headers : array<string|int, mixed>
Return values
AbstractClient —createAsJson()
Create request as JSON
public
createAsJson() : AbstractClient
Return values
AbstractClient —createMultipartForm()
Create request as a multipart form
public
createMultipartForm() : AbstractClient
Return values
AbstractClient —createUrlEncodedForm()
Create request as a URL-encoded form
public
createUrlEncodedForm() : AbstractClient
Return values
AbstractClient —curl()
Return cURL resource (alias to $this->getResource())
public
curl() : resource
Return values
resource —disconnect()
Close the cURL connection
public
disconnect() : void
Return values
void —getField()
Get a field
public
getField(string $name) : mixed
Parameters
- $name : string
Return values
mixed —getFields()
Get all field
public
getFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —getInfo()
Return the cURL session last info
public
getInfo([int $opt = null ]) : array<string|int, mixed>|string
Parameters
- $opt : int = null
Return values
array<string|int, mixed>|string —getMethod()
Get the method
public
getMethod() : string
Return values
string —getOption()
Get a cURL session option
public
getOption(int $opt) : string
Parameters
- $opt : int
Return values
string —getParsedResponse()
Get the parsed response
public
getParsedResponse() : mixed
Return values
mixed —getRequest()
Get the request object
public
getRequest() : Request
Return values
Request —getRequestBody()
Get the request body
public
getRequestBody() : string
Return values
string —getRequestHeader()
Get the request header
public
getRequestHeader(string $name) : mixed
Parameters
- $name : string
Return values
mixed —getRequestHeaders()
Get the request headers
public
getRequestHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed> —getResource()
Get the resource
public
getResource() : resource
Return values
resource —getResponse()
Get the response object
public
getResponse() : Response
Return values
Response —getResponseBody()
Get the response body
public
getResponseBody() : string
Return values
string —getResponseCode()
Get the response code
public
getResponseCode() : string
Return values
string —getResponseHeader()
Get the response header
public
getResponseHeader(string $name) : mixed
Parameters
- $name : string
Return values
mixed —getResponseHeaders()
Get the response headers
public
getResponseHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed> —getUrl()
Get the URL
public
getUrl() : string
Return values
string —hasOption()
Has a cURL session option
public
hasOption(int $opt) : bool
Parameters
- $opt : int
Return values
bool —hasRequest()
Has request object
public
hasRequest() : bool
Return values
bool —hasRequestHeader()
Has request header
public
hasRequestHeader(string $name) : bool
Parameters
- $name : string
Return values
bool —hasRequestHeaders()
Has request headers
public
hasRequestHeaders() : bool
Return values
bool —hasResource()
Determine whether or not resource is available
public
hasResource() : bool
Return values
bool —hasResponse()
Has response object
public
hasResponse() : bool
Return values
bool —hasResponseHeader()
Has response header
public
hasResponseHeader(string $name) : bool
Parameters
- $name : string
Return values
bool —hasResponseHeaders()
Has response headers
public
hasResponseHeaders() : bool
Return values
bool —isJson()
Check if request is JSON
public
isJson() : bool
Return values
bool —isMultipartForm()
Check if request is a multipart form
public
isMultipartForm() : bool
Return values
bool —isReturnHeader()
Check if cURL is set to return header
public
isReturnHeader() : bool
Return values
bool —isReturnTransfer()
Check if cURL is set to return transfer
public
isReturnTransfer() : bool
Return values
bool —isUrlEncodedForm()
Check if request is a URL-encoded form
public
isUrlEncodedForm() : bool
Return values
bool —open()
Create and open cURL resource
public
open() : Curl
Return values
Curl —removeField()
Remove a field
public
removeField(string $name) : AbstractClient
Parameters
- $name : string
Return values
AbstractClient —removeFields()
Remove all fields
public
removeFields() : AbstractClient
Return values
AbstractClient —request()
Get the request object (alias method)
public
request() : Request
Return values
Request —resource()
Get the resource (alias method)
public
resource() : resource
Return values
resource —response()
Get the response object (alias method)
public
response() : Response
Return values
Response —send()
Method to send the request and get the response
public
send() : void
Return values
void —setField()
Set a field
public
setField(string $name, mixed $value) : AbstractClient
Parameters
- $name : string
- $value : mixed
Return values
AbstractClient —setFields()
Set all fields
public
setFields(array<string|int, mixed> $fields) : AbstractClient
Parameters
- $fields : array<string|int, mixed>
Return values
AbstractClient —setMethod()
Set the method
public
setMethod(string $method[, bool $strict = true ]) : Curl
Parameters
- $method : string
- $strict : bool = true
Tags
Return values
Curl —setOption()
Set cURL session option
public
setOption(int $opt, mixed $val) : Curl
Parameters
- $opt : int
- $val : mixed
Return values
Curl —setOptions()
Set cURL session options
public
setOptions(array<string|int, mixed> $opts) : Curl
Parameters
- $opts : array<string|int, mixed>
Return values
Curl —setRequest()
Set the request object
public
setRequest(Request $request) : AbstractClient
Parameters
- $request : Request
Return values
AbstractClient —setResponse()
Set the response object
public
setResponse(Response $response) : AbstractClient
Parameters
- $response : Response
Return values
AbstractClient —setReturnHeader()
Set cURL option to return the header
public
setReturnHeader([bool $header = true ]) : Curl
Parameters
- $header : bool = true
Return values
Curl —setReturnTransfer()
Set cURL option to return the transfer
public
setReturnTransfer([bool $transfer = true ]) : Curl
Parameters
- $transfer : bool = true
Return values
Curl —setUrl()
Set the URL
public
setUrl(string $url) : AbstractClient
Parameters
- $url : string
Return values
AbstractClient —throwError()
Throw an exception upon an error.
public
throwError(string $error) : void
Parameters
- $error : string
Tags
Return values
void —version()
Return the cURL version
public
version() : array<string|int, mixed>