View on GitHub

Spire

REST interface for mongodb

Download this project as a .zip file Download this project as a tar.gz file

spire

spire is a REST interface for mongodb instances.

spire

installation

clone the repository.

 $ git clone https://github.com/emre/spire.git

install the dependencies.

 $ composer install

that's all. next is step is configuring your webserver.

getting started

you can test your api from your command line.

getting a list of items

curl --dump-header -X get 'http://localhost:8090/users/'

adding an item

curl --dump-header - -H "Content-Type: application/json" -X POST --data '{"first_name":"John", "last_name":"Doe", "location": "Miami, FL"}' http://localhost/users/

updating an item

curl --dump-header - -H "Content-Type: application/json" -X PUT --data '{"first_name":"Jane", "last_name": "Brown"}' http://localhost/users/:USER_ID:/

bundles

you can represent entries in your way. add your custom Resource class to custom_resource.php like this:

class CustomResource extends \Spire\Resources\Resource {

    public function build_users_bundle($data) {
        $data["fullname"] = sprintf("%s %s", $data["first_name"], $data["last_name"]);
        return $data;
    }

}

point it out in your settings.php:

$RESOURCE_CLASS = 'CustomResource';

supported methods

Method Path Action
GET /users Returns all records. offset and limit parameters supported for pagination
GET /users/:id Returns a single document
POST /users Creates a new document
PUT /users/:id Replaces an existing document
DELETE /users/:id Removes an existing document

running tests

 $ vendor/bin/phpunit tests/SpireTest.php

note