MLPHP


MLPHP\RESTClient
MarkLogic/MLPHP/RESTClient.php at line 28

Class RESTClient

RESTClient

public class RESTClient

Represents a REST client.

Author:
Mike Wooldridge

Constructor Summary
void

__construct(str host, int port, str path, str version, str username, str password, str auth, mixed logger)

Method Summary
void

setHost(string host)

Set the host.

void

setPort(string port)

Set the port.

void

setPath(string path)

Set the path.

void

setVersion(string version)

Set the version.

void

setUsername(string username)

Set the username.

void

setPassword(string password)

Set the password.

void

setAuth(string auth)

Set the authentication scheme.

void

setPrefix(string prefix)

Set the URL prefix.

string

getPrefix()

Get the URL prefix.

void

setLogger(LoggerInterface logger)

Set the logger.

LoggerInterface

getLogger()

Get the logger.

RESTResponse

send(RESTRequest request)

Send a REST request.

protected array

setOptions(resource ch, string url, array headers, mixed urlStr)

Set cURL options common to all requests

RESTResponse

get(RESTRequest request)

Perform a GET request with cURL

RESTResponse

put(RESTRequest request)

Perform a PUT request with cURL

RESTResponse

delete(RESTRequest request)

Perform a DELETE request with cURL

RESTResponse

post(RESTRequest request)

Perform a POST request with cURL

RESTResponse

head(RESTRequest request)

Perform a HEAD request with cURL

protected RESTResponse

execute(resource ch)

Execute a cURL request.

void

installExtension($resource URL, $params resource, $filename file, mixed params, mixed filename)

Install a REST API XQuery extension

Constructor Detail

MarkLogic/MLPHP/RESTClient.php at line 53

__construct

public void __construct(str host, int port, str path, str version, str username, str password, str auth, mixed logger)

Method Detail

MarkLogic/MLPHP/RESTClient.php at line 92

setHost

public void setHost(string host)

Set the host.

Parameters:
host - The host (examples: 'localhost', 'test.marklogic.com', '192.162.5.1').

MarkLogic/MLPHP/RESTClient.php at line 102

setPort

public void setPort(string port)

Set the port.

Parameters:
port - The port (example: 8003).

MarkLogic/MLPHP/RESTClient.php at line 112

setPath

public void setPath(string path)

Set the path.

Parameters:
path - The path (example: 'api').

MarkLogic/MLPHP/RESTClient.php at line 122

setVersion

public void setVersion(string version)

Set the version.

Parameters:
version - The API version (example: 'v1').

MarkLogic/MLPHP/RESTClient.php at line 132

setUsername

public void setUsername(string username)

Set the username.

Parameters:
username - The username for REST authentication.

MarkLogic/MLPHP/RESTClient.php at line 142

setPassword

public void setPassword(string password)

Set the password.

Parameters:
password - The password for REST authentication.

MarkLogic/MLPHP/RESTClient.php at line 152

setAuth

public void setAuth(string auth)

Set the authentication scheme.

Parameters:
auth - The authentication scheme (examples: 'basic', 'digest').

MarkLogic/MLPHP/RESTClient.php at line 162

setPrefix

public void setPrefix(string prefix)

Set the URL prefix. Allows you to create a custom URL when no arguments are passed at construction.

Parameters:
prefix - The URL prefix.

MarkLogic/MLPHP/RESTClient.php at line 172

getPrefix

public string getPrefix()

Get the URL prefix.

Returns:
The URL prefix.

MarkLogic/MLPHP/RESTClient.php at line 182

setLogger

public void setLogger(LoggerInterface logger)

Set the logger.


MarkLogic/MLPHP/RESTClient.php at line 192

getLogger

public LoggerInterface getLogger()

Get the logger.


MarkLogic/MLPHP/RESTClient.php at line 203

send

public RESTResponse send(RESTRequest request)

Send a REST request.

Parameters:
request - A RESTRequest object
Returns:
A RESTResponse object.

MarkLogic/MLPHP/RESTClient.php at line 238

setOptions

protected array setOptions(resource ch, string url, array headers, mixed urlStr)

Set cURL options common to all requests

Parameters:
ch - The cURL handle.
url - The REST URL string (example: 'documents').
headers - Optional assoc array of headers.
Returns:
An array of cURL options.

MarkLogic/MLPHP/RESTClient.php at line 269

get

public RESTResponse get(RESTRequest request)

Perform a GET request with cURL

Parameters:
request - A REST request.
Returns:
A REST response.

MarkLogic/MLPHP/RESTClient.php at line 290

put

public RESTResponse put(RESTRequest request)

Perform a PUT request with cURL

Parameters:
request - A REST request.
Returns:
A REST response.

MarkLogic/MLPHP/RESTClient.php at line 324

delete

public RESTResponse delete(RESTRequest request)

Perform a DELETE request with cURL

Parameters:
request - A REST request.
Returns:
A REST response.

MarkLogic/MLPHP/RESTClient.php at line 345

post

public RESTResponse post(RESTRequest request)

Perform a POST request with cURL

Parameters:
request - A REST request.
Returns:
A REST response.

MarkLogic/MLPHP/RESTClient.php at line 378

head

public RESTResponse head(RESTRequest request)

Perform a HEAD request with cURL

Parameters:
request - A REST request.
Returns:
A REST response.

MarkLogic/MLPHP/RESTClient.php at line 402

execute

protected RESTResponse execute(resource ch)

Execute a cURL request.

Todo:
Handle more response codes
Parameters:
ch - The REST URL string (example: 'documents')
Returns:
A RESTResponse object.

MarkLogic/MLPHP/RESTClient.php at line 445

installExtension

public void installExtension($resource URL, $params resource, $filename file, mixed params, mixed filename)

Install a REST API XQuery extension

Parameters:
resource - parameters (adds in provider=MLPHP if provider not set)
file - system name of contents of the XQuery module.

MLPHP