Simple REST crud server.

dev-master 2012-12-27 13:11 UTC

This package is not auto-updated.

Last update: 2024-11-09 15:39:27 UTC


README

Simple REST crud server.

Build Status

model objects will share the interface:

<?php

namespace Rest;

use \Symfony\Component\HttpFoundation\Request;

interface Iface
{
    public function __construct($id, \PDO $pdo);

    public function get();

    public function delete();

    public function update(Request $request);

    public function create(Request $request);

    public static function getAll(Request $request);
}

initialize the server mapping the model to the real class names:

<?php
// index.php
use Rest\App;

$app = App::create(new \PDO('sqlite::memory:'));

$app->register('dogs', '\App\Dogs');
$app->register('cats', '\App\Cats');

$app->getResponse()->send();

The server will handle GET request to get(), DELETE to delete(), POST to update() and CREATE to create().

If we perform a GET request without id (null) then the static getAll is raised