Download the PHP package smalldb/smalldb-rest without Composer
On this page you can find all versions of the php package smalldb/smalldb-rest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download smalldb/smalldb-rest
More information about smalldb/smalldb-rest
Files in smalldb/smalldb-rest
Package smalldb-rest
Short Description Simple REST API for Smalldb
License Apache-2.0
Homepage https://smalldb.org/
Informations about the package smalldb-rest
Smalldb-REST
Simple implementation of REST API for Smalldb.
Requirements
- PHP 5.5+
- libsmalldb
Installation
- Use
composer install
to install all libraries. - Create
api-v1.php
andapi-v1-diagram.php
as in examples. - Create state machine definitions in
statemachine
directory -- see libsmalldb documentation for details. - Before use in production environment change the
auth.class
option to something less permissive. -- Theconfig.json.php
contains option to allow everything. The default is to useCookieAuth
class, but that requires some configuration.
Configuration
Configuration is loaded from three JSON files. Later overwrites the previous
(using array_replace_recursive
function).
config.json.php
in Smalldb-REST's directory to load default values.config.app.json.php
in the project's root directory to load application-specific options. This file should be under version control, do not put sensitive informations here.config.local.json.php
in the project's root directory to load installation-specific options. This file should NOT be under version control (put it into.gitignore
), it is meant to contain sensitive informations.
To achieve forward compatibility of your configuration files do not use whole copy of default config file in your application. Set only changed options instead.
API Usage
Read state of a state machine (machine ID = "blogpost", 1
):
Read transition info of a state machine (transition edit
):
Invoke transition of a state machine (transition edit
, parameters are passed
via $_POST['args']
):
List state machines of given type:
State diagram renderer
The second function of the REST API is state diagram renderer. To retrieve
state diagram of the blogpost
state machine use following HTTP request:
This mean you can simply put this HTML to your application:
Note: Diagrams are rendered using Graphviz and cached using APC. The dot
executable must be somewhere in PHP's PATH.
LICENSE
Apache 2.0 - see LICENSE file