Smalldb-REST  v0.5-5-gff393ee
Static Public Member Functions | Public Attributes | List of all members
Application Class Reference

Description

The REST API application.

Simply call Application::main(__DIR__) and it should work.

Parameters
$base_dirBase directory, where config.app.json.php is located.
$taskSelect what this PHP script shall do – see TASK_* constants.
Note
This class is a bit ugly to allow use of various parts from tests. The only real public API is the main() method.

Static Public Member Functions

static initialize ($base_dir)
 Initialize environment. More...
 
static main ($base_dir, $task=self::TASK_API)
 The main() More...
 
static renderStateMachine (\Smalldb::StateMachine::AbstractBackend $smalldb, $machine, $format)
 Render state diagram. More...
 
static performSelfCheck (\Smalldb::StateMachine::AbstractBackend $smalldb)
 Perform self-check. More...
 

Public Attributes

const TASK_INIT = 'init'
 Initialization only (for custom scripts) More...
 
const TASK_API = 'api'
 Implement Smalldb JSON REST API. More...
 
const TASK_DIAGRAM = 'diagram'
 State diagram renderer ($_GET params: machine, format (dot, png, pdf, svg)) More...
 
const TASK_SELFCHECK = 'selfcheck'
 Perform a quick self-check to detect most common errors. More...
 

Helper methods

Note
These methods are not public API and they are likely to be changed.
static loadConfig ($base_dir)
 Load configuration from three files (defaults, app, local) and merge it. More...
 
static createSmalldb ($config)
 Create and initialize Smalldb, including Flupdo and Auth objects. More...
 
static createRouter ($config, $handler)
 Create API handler. More...
 
static createHandler ($config, $smalldb)
 Create handler, which processes all API requests from router. More...
 

Member Function Documentation

static initialize (   $base_dir)
static

Initialize environment.

Usage:

require __DIR__."/vendor/autoload.php";
list($config, $smalldb) = Smalldb::Rest::Application::initialize(__DIR__);
Returns
[$config, $smalldb]
static main (   $base_dir,
  $task = self::TASK_API 
)
static

The main()

static loadConfig (   $base_dir)
static

Load configuration from three files (defaults, app, local) and merge it.

static createSmalldb (   $config)
static

Create and initialize Smalldb, including Flupdo and Auth objects.

static createRouter (   $config,
  $handler 
)
static

Create API handler.

static createHandler (   $config,
  $smalldb 
)
static

Create handler, which processes all API requests from router.

static renderStateMachine ( \Smalldb::StateMachine::AbstractBackend  $smalldb,
  $machine,
  $format 
)
static

Render state diagram.

static performSelfCheck ( \Smalldb::StateMachine::AbstractBackend  $smalldb)
static

Perform self-check.

Member Data Documentation

const TASK_INIT = 'init'

Initialization only (for custom scripts)

const TASK_API = 'api'

Implement Smalldb JSON REST API.

const TASK_DIAGRAM = 'diagram'

State diagram renderer ($_GET params: machine, format (dot, png, pdf, svg))

const TASK_SELFCHECK = 'selfcheck'

Perform a quick self-check to detect most common errors.