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

The REST API application. More...

Static Public Member Functions

static main ($base_dir, $task=self::TASK_API)
 The main() More...
 

Public Attributes

const TASK_API = 'api'
 Implement Smalldb JSON REST API.
 
const TASK_DIAGRAM = 'diagram'
 State diagram renderer ($_GET params: machine, format (dot, png, pdf, svg))
 

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.
 
static createSmalldb ($config)
 Create and initialize Smalldb, including Flupdo and Auth objects.
 
static createRouter ($config, $handler)
 Create API handler.
 
static createHandler ($config, $smalldb)
 Create handler, which processes all API requests from router.
 
static renderStateMachine (\Smalldb::StateMachine::AbstractBackend $smalldb, $machine, $format)
 Render state diagram.
 

Detailed 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.

Member Function Documentation

static main (   $base_dir,
  $task = self::TASK_API 
)
static

The main()

Todo:
Replace switch with something nice

Here is the call graph for this function: