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.

void

send(RESTRequest request)

Send a REST request.

protected void

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

Set cURL options common to all requests

void

get(RESTRequest request)

Perform a GET request with cURL

void

put(RESTRequest request)

Perform a PUT request with cURL

void

delete(RESTRequest request)

Perform a DELETE request with cURL

void

post(RESTRequest request)

Perform a POST request with cURL

void

head(RESTRequest request)

Perform a HEAD request with cURL

void

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 void send(RESTRequest request)

Send a REST request.

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

MarkLogic/MLPHP/RESTClient.php at line 237

setOptions

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

Set cURL options common to all requests

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

MarkLogic/MLPHP/RESTClient.php at line 262

get

public void get(RESTRequest request)

Perform a GET request with cURL

Parameters:
request - A REST request.
Result:
RESTResponse A REST response.

MarkLogic/MLPHP/RESTClient.php at line 283

put

public void put(RESTRequest request)

Perform a PUT request with cURL

Parameters:
request - A REST request.
Result:
RESTResponse A REST response.

MarkLogic/MLPHP/RESTClient.php at line 320

delete

public void delete(RESTRequest request)

Perform a DELETE request with cURL

Parameters:
request - A REST request.
Result:
RESTResponse A REST response.

MarkLogic/MLPHP/RESTClient.php at line 341

post

public void post(RESTRequest request)

Perform a POST request with cURL

Parameters:
request - A REST request.
Result:
RESTResponse A REST response.

MarkLogic/MLPHP/RESTClient.php at line 378

head

public void head(RESTRequest request)

Perform a HEAD request with cURL

Parameters:
request - A REST request.
Result:
RESTResponse A REST response.

MarkLogic/MLPHP/RESTClient.php at line 402

execute

public void execute(resource ch)

Execute a cURL request.

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

MarkLogic/MLPHP/RESTClient.php at line 433

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