PHP Class Remote

Author: Kevin Hutchinson ([email protected])
Inheritance: extends Relating_model, implements Modelled, implements Persisted, implements Validated
Show file Open project: getkirby/toolkit Class Usage Examples

Public Properties

Property Type Description
$defaults configuration

Protected Properties

Property Type Description
$headers all received headers
$options all options for the request
$response store for the response object

Public Methods

Method Description
__construct ( string $url, array $options = [] ) Constructor
delete ( string $url, array $params = [] ) : object Static method to send a DELETE request
get ( string $url, array $params = [] ) : object Static method to send a GET request
head ( string $url, array $params = [] ) : object Static method to send a HEAD request
headers ( string $url, array $params = [] ) : array Static method to send a HEAD request which only returns an array of headers
options ( ) : array Returns all options which have been set for the current request
post ( string $url, array $params = [] ) : object Static method to send a POST request
put ( string $url, array $params = [] ) : object Static method to send a PUT request
request ( string $url, array $params = [] ) : object Static method to init this class and send a request
response ( ) : object Returns the response object for the current request

Protected Methods

Method Description
header ( object $curl, string $header ) : integer Used by curl to parse incoming headers
postfields ( mixed $data ) : mixed Internal method to handle post field data
send ( ) : object Sets up all curl options and sends the request

Method Details

__construct() public method

Constructor
public __construct ( string $url, array $options = [] )
$url string
$options array

delete() public static method

Static method to send a DELETE request
public static delete ( string $url, array $params = [] ) : object
$url string
$params array
return object Response

get() public static method

Static method to send a GET request
public static get ( string $url, array $params = [] ) : object
$url string
$params array
return object Response

head() public static method

Static method to send a HEAD request
public static head ( string $url, array $params = [] ) : object
$url string
$params array
return object Response

header() protected method

Used by curl to parse incoming headers
protected header ( object $curl, string $header ) : integer
$curl object the curl connection
$header string the header line
return integer the length of the heade

headers() public static method

Static method to send a HEAD request which only returns an array of headers
public static headers ( string $url, array $params = [] ) : array
$url string
$params array
return array

options() public method

Returns all options which have been set for the current request
public options ( ) : array
return array

post() public static method

Static method to send a POST request
public static post ( string $url, array $params = [] ) : object
$url string
$params array
return object Response

postfields() protected method

Internal method to handle post field data
protected postfields ( mixed $data ) : mixed
$data mixed
return mixed

put() public static method

Static method to send a PUT request
public static put ( string $url, array $params = [] ) : object
$url string
$params array
return object Response

request() public static method

Static method to init this class and send a request
public static request ( string $url, array $params = [] ) : object
$url string
$params array
return object Response

response() public method

Returns the response object for the current request
public response ( ) : object
return object Response

send() protected method

Sets up all curl options and sends the request
protected send ( ) : object
return object Response

Property Details

$defaults public static property

configuration
public static $defaults

$headers protected property

all received headers
protected $headers

$options protected property

all options for the request
protected $options

$response protected property

store for the response object
protected $response