2017 © Pedro Peláez
 

library drapi

A framework to create and manage API services

image

hiraq/drapi

A framework to create and manage API services

  • Saturday, July 27, 2013
  • by hiraq
  • Repository
  • 2 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

drapi

A framework to create and manage API (REST) services, (*1)

Build Status Coverage Status Latest Stable Version Total Downloads project status, (*2)

usage

Put this codes in your index.php file., (*3)

<?php
require_once 'vendor/autoload.php';

use Drapi\Router;
use Drapi\Request as DrapiRequest;
use Drapi\Response as DrapiResponse;
use Drapi\Handler;
use Drapi\Compiler;

try {

    $router = new Router;
    $request = new DrapiRequest;
    $response = new DrapiResponse;
    $handler = new Handler;

    $compiler = new Compiler($router,$request,$response);
    $compiler->setHandlerNameSpace('Drapi\\Handler\\');
    $compiler->setHandler($handler);
    $compiler->compile();

} catch (Exception $e) {
    echo $e->getMessage();
}

Then try to open your browser, and go to, (*4)

  1. http://localhost/myapi/test or http://localhost/myapi/test/get
  2. http://localhost/myapi/testing for failed data response example
  3. http://php.drapi/test/test_param?key1=val1&key2=val2 for GET parameters example

Drapi doesn't need any rewrite rules!, (*5)

handler

A handler is class to manage and return a data from your datasource (MySQL,Postgre,Mongodb,etc).
Create a handler class inside Drapi/Handler, such as Users.php. Everytime your server get a API request based on: '/users/get', then your handler (Users.php) will be loaded and will use method get inside Users class. See Test.php inside Drapi/Handler for example., (*6)

plugin

A plugin is an extension for your handler class, create a class such as Mongo.php in Drapi/Handler/Plugin and load this class inside your handler class (autoload)., (*7)

response

All Drapi response is a data formatted in json. If any request that fail to call a handler or maybe there are no valid data available, then Drapi will automatically give an error status and message., (*8)

license

Drapi is released under the BSD 3-Clause License. See LICENSE.txt file for details., (*9)

The Versions

27/07 2013

dev-master

9999999-dev

A framework to create and manage API services

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Avatar hiraq

api json rest

27/07 2013

v1.0.0-beta1

1.0.0.0-beta1

A framework to create and manage API services

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Avatar hiraq

api json rest