Overview

Packages

  • CodeIgniter
    • Libraries
  • None

Classes

  • Example
  • Key
  • REST_Controller
  • Overview
  • Package
  • Class
  • Tree
  • Todo

Class REST_Controller

CodeIgniter Rest Controller

A fully RESTful server implementation for CodeIgniter using one library, one config file and one controller.

CI_Controller
Extended by REST_Controller

Direct known subclasses

Example, Key
Abstract
Package: CodeIgniter\Libraries
Category: Libraries
License: MIT
Author: Phil Sturgeon, Chris Kacerguis
Version: 3.0.0-pre
Link: https://github.com/chriskacerguis/codeigniter-restserver
Located at application/libraries/REST_Controller.php
Methods summary
protected
# early_checks( )

Developers can extend this class and add a check in here.

Developers can extend this class and add a check in here.

public
# __construct( $config = 'rest' )

Constructor function

Constructor function

Todo

Document more please.
public
# __destruct( )

Destructor function

Destructor function

Author

Chris Kacerguis
public
# _remap( string $object_called, array $arguments )

Remap

Remap

Requests are not made to methods directly, the request will be for an "object". This simply maps the object and method to the correct Controller method.

Parameters

$object_called
$arguments
The arguments passed to the controller method.
protected
# _fire_method( array $method, array $args )

Fire Method

Fire Method

Fires the designated controller method with the given arguments.

Parameters

$method
The controller method to fire
$args
The arguments to pass to the controller method
public
# response( array $data = NULL, null|integer $http_code = NULL, boolean $continue = FALSE )

Response

Response

Takes pure data and optionally a status code, then creates the response. Set $continue to TRUE to flush the response to the client and continue running the script.

Parameters

$data
$http_code
$continue
protected
# _detect_ssl( )
protected
# _detect_input_format( )
protected string
# _detect_output_format( )

Detect format

Detect format

Detect which format should be used to output the data.

Returns

string
The output format.
protected string
# _detect_method( )

Detect method

Detect method

Detect which HTTP method is being used

Returns

string
protected boolean
# _detect_api_key( )

Detect API Key

Detect API Key

See if the user has provided an API key

Returns

boolean
protected null|string
# _detect_lang( )

Detect language(s)

Detect language(s)

What language do they want it in?

Returns

null|string
The language code.
protected object
# _log_request( boolean $authorized = FALSE )

Log request

Log request

Record the entry for awesomeness purposes

Parameters

$authorized

Returns

object
protected boolean
# _check_limit( string $controller_method )

Limiting requests

Limiting requests

Check if the requests are coming in a tad too fast.

Parameters

$controller_method
The method being called.

Returns

boolean
protected boolean
# _auth_override_check( )

Auth override check

Auth override check

Check if there is a specific auth type set for the current class/method being called.

Returns

boolean
protected
# _parse_get( )

Parse GET

Parse GET

protected
# _parse_post( )

Parse POST

Parse POST

protected
# _parse_put( )

Parse PUT

Parse PUT

protected
# _parse_head( )

Parse HEAD

Parse HEAD

protected
# _parse_options( )

Parse OPTIONS

Parse OPTIONS

protected
# _parse_patch( )

Parse PATCH

Parse PATCH

protected
# _parse_delete( )

Parse DELETE

Parse DELETE

public string
# get( string $key = NULL, boolean $xss_clean = TRUE )

Retrieve a value from the GET request arguments.

Retrieve a value from the GET request arguments.

Parameters

$key
The key for the GET request argument to retrieve
$xss_clean
Whether the value should be XSS cleaned or not.

Returns

string
The GET argument value.
public string
# options( string $key = NULL, boolean $xss_clean = TRUE )

This function retrieves a values from the OPTIONS request arguments

This function retrieves a values from the OPTIONS request arguments

Parameters

$key
The OPTIONS/GET argument key
$xss_clean
Whether the value should be XSS cleaned or not

Returns

string
The OPTIONS/GET argument value
public string
# head( string $key = NULL, boolean $xss_clean = TRUE )

This function retrieves a values from the HEAD request arguments

This function retrieves a values from the HEAD request arguments

Parameters

$key
The HEAD/GET argument key
$xss_clean
Whether the value should be XSS cleaned or not

Returns

string
The HEAD/GET argument value
public string
# post( string $key = NULL, boolean $xss_clean = TRUE )

Retrieve a value from the POST request arguments.

Retrieve a value from the POST request arguments.

Parameters

$key
The key for the POST request argument to retrieve
$xss_clean
Whether the value should be XSS cleaned or not.

Returns

string
The POST argument value.
public string
# put( string $key = NULL, boolean $xss_clean = TRUE )

Retrieve a value from the PUT request arguments.

Retrieve a value from the PUT request arguments.

Parameters

$key
The key for the PUT request argument to retrieve
$xss_clean
Whether the value should be XSS cleaned or not.

Returns

string
The PUT argument value.
public string
# delete( string $key = NULL, boolean $xss_clean = TRUE )

Retrieve a value from the DELETE request arguments.

Retrieve a value from the DELETE request arguments.

Parameters

$key
The key for the DELETE request argument to retrieve
$xss_clean
Whether the value should be XSS cleaned or not.

Returns

string
The DELETE argument value.
public string
# patch( string $key = NULL, boolean $xss_clean = TRUE )

Retrieve a value from the PATCH request arguments.

Retrieve a value from the PATCH request arguments.

Parameters

$key
The key for the PATCH request argument to retrieve
$xss_clean
Whether the value should be XSS cleaned or not.

Returns

string
The PATCH argument value.
protected string
# _xss_clean( string $val, boolean $process )

Process to protect from XSS attacks.

Process to protect from XSS attacks.

Parameters

$val
The input.
$process
Do clean or note the input.

Returns

string
public array
# validation_errors( )

Retrieve the validation errors.

Retrieve the validation errors.

Returns

array
protected boolean
# _perform_ldap_auth( string $username = '', string $password = NULL )

Perform LDAP Authentication

Perform LDAP Authentication

Parameters

$username
The username to validate
$password
The password to validate

Returns

boolean
protected boolean
# _perform_library_auth( string $username = '', string $password = NULL )

Perform Library Authentication - Override this function to change the way the library is called

Perform Library Authentication - Override this function to change the way the library is called

Parameters

$username
The username to validate
$password
The password to validate

Returns

boolean
protected boolean
# _check_login( string $username = '', string $password = FALSE )

Check if the user is logged in.

Check if the user is logged in.

Parameters

$username
The user's name
$password
The user's password

Returns

boolean
protected
# _check_php_session( )

Check to see if the user is logged into the web app with a php session key.

Check to see if the user is logged into the web app with a php session key.

protected
# _prepare_basic_auth( )

Todo

document this.
protected
# _prepare_digest_auth( )

Todo

Document this.
protected
# _check_blacklist_auth( )

Check if the client's ip is in the 'rest_ip_blacklist' config

Check if the client's ip is in the 'rest_ip_blacklist' config

protected
# _check_whitelist_auth( )

Check if the client's ip is in the 'rest_ip_whitelist' config

Check if the client's ip is in the 'rest_ip_whitelist' config

protected
# _force_login( string $nonce = '' )

Parameters

$nonce

Todo

Document this.
protected array
# _force_loopable( object|array $data )

Force it into an array

Force it into an array

Parameters

$data

Returns

array
protected boolean
# _log_access_time( )

updates the log with the access time

updates the log with the access time

Returns

boolean

Author

Chris Kacerguis
protected boolean
# _check_access( )

Check to see if the API key has access to the controller and methods

Check to see if the API key has access to the controller and methods

Returns

boolean
Properties summary
protected string|null $rest_format

This defines the rest format.

This defines the rest format.

Must be overridden it in a controller so that it is set.

# NULL
protected array $methods

Defines the list of method properties such as limit, log and level

Defines the list of method properties such as limit, log and level

# array()
protected array $allowed_http_methods

List of allowed HTTP methods

List of allowed HTTP methods

# array('get', 'delete', 'post', 'put', 'options', 'patch', 'head')
protected object $request

General request data and information. Stores accept, language, body, headers, etc.

General request data and information. Stores accept, language, body, headers, etc.

# NULL
protected object $response

What is gonna happen in output?

What is gonna happen in output?

# NULL
protected object $rest

Stores DB, keys, key level, etc

Stores DB, keys, key level, etc

# NULL
protected array $_get_args

The arguments for the GET request method

The arguments for the GET request method

# array()
protected array $_post_args

The arguments for the POST request method

The arguments for the POST request method

# array()
protected string $_insert_id

The insert_id of the log entry (if we have one)

The insert_id of the log entry (if we have one)

# ''
protected array $_put_args

The arguments for the PUT request method

The arguments for the PUT request method

# array()
protected array $_delete_args

The arguments for the DELETE request method

The arguments for the DELETE request method

# array()
protected array $_patch_args

The arguments for the PATCH request method

The arguments for the PATCH request method

# array()
protected array $_head_args

The arguments for the HEAD request method

The arguments for the HEAD request method

# array()
protected array $_options_args

The arguments for the OPTIONS request method

The arguments for the OPTIONS request method

# array()
protected array $_args

The arguments from GET, POST, PUT, DELETE request methods combined.

The arguments from GET, POST, PUT, DELETE request methods combined.

# array()
protected boolean $_allow

If the request is allowed based on the API key provided.

If the request is allowed based on the API key provided.

# TRUE
protected boolean $_zlib_oc

Determines if output compression is enabled

Determines if output compression is enabled

# FALSE
protected string $_user_ldap_dn

The LDAP Distinguished Name of the User post authentication

The LDAP Distinguished Name of the User post authentication

# ''
protected string $_start_rtime

The start of the response time from the server

The start of the response time from the server

# ''
protected string $_end_rtime

The end of the response time from the server

The end of the response time from the server

# ''
protected array $_supported_formats

List all supported methods, the first will be the default format

List all supported methods, the first will be the default format

# array( 'xml' => 'application/xml', 'json' => 'application/json', 'jsonp' => 'application/javascript', 'serialized' => 'application/vnd.php.serialized', 'php' => 'text/plain', 'html' => 'text/html', 'csv' => 'application/csv' )
protected object $_apiuser

Information about the current API user

Information about the current API user

#
API documentation generated by ApiGen