Coder Social home page Coder Social logo

spire's Introduction

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

  • This a remembering PHP project for me since I did not write a single line of PHP for like 3 years. Any contributions to make it better will be accepted.

  • see @fatiherikli's kule for a python/better alternative.

spire's People

Contributors

emre avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.