PHP Classes

PHP RESTful API Framework Kit: MVC framework to implement REST APIs

Recommend this page to a friend!
  Info   View files Example   View files View files (24)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 385 This week: 1All time: 6,688 This week: 560Up
Version License PHP version Categories
php-api-kit 1.0.0MIT/X Consortium ...5PHP 5, Libraries, Web services
Description 

Author

This package is a MVC framework to implement REST APIs.

It provides a base controller, a base model and a router to process REST API requests and dispatch them to controller classes that handle the configured requests.

The API end points mappings to controller classes are defined in configuration scripts.

The API responses are outputted in JSON format.

Picture of Rogério Taques
Name: Rogério Taques <contact>
Classes: 4 packages by
Country: Japan Japan
Age: ???
All time rank: 237310 in Japan Japan
Week rank: 416 Up2 in Japan Japan Up

Example

<?php

 
/* --------------------------------------------------------
 | PHP API KIT
 | @author Rogerio Taques (rogerio.taques@gmail.com)
 | @version 0.1
 | @license MIT
 | @see http://github.com/rogeriotaques/php-api-kit
 * -------------------------------------------------------- */
 
// define the api timezone
date_default_timezone_set('Asia/Tokyo');

// is the system been updated?
if (file_exists('.update.lock')) {
  echo
json_encode( ['status' => 503, 'message' => 'Service temporarely unavailable. Update in progress.'] );
  exit;
}

// let's define the environment
// it can be whatever you want. usually will be either 'development' or 'production'
if (!defined('ENV')) {
 
define('ENV', getenv('ENV') !== false ? getenv('ENV') : 'development');
}

if (
defined('ENV')) {

    switch (
ENV)
    {
        case
'development':
           
error_reporting(E_ALL & ~E_NOTICE);
            break;
   
        case
'testing':
        case
'production':
           
error_reporting(0);
            break;

        default:
            exit(
'The application environment is not set correctly.');
    }

}

// import loader ...
if (!require_once('seed/loader.php')) {
  die(
"Loader not found! Aborted.");
}

use
Seed\Router;

// retrieve requested URI
$uri = isset($_GET['uri']) ? $_GET['uri'] : '';

// initialise the router
$router = Router::getInstance( $uri );

// let's rock ...
$router->run();


Details

PHP API KIT

Is a library kit, aka framework, that helps you to implement a RESTful API using PHP.

It's a simple and very lightweight framework, with a really small footprint, specially designed for APIs development and absolutelly not for MVC applications. Of course its source code architecure has some similarities to MVC frameworks, but instead of using views for output, its outputs are string JSON encoded.

In the case you wanna something for MVC applications give a try on Codeigniter or Zend Framework.

Get started

Clone this repository or download this project. Once you have the source files, you can start working on it. It's documentation and help pages are not ready (yet), but simply by looking at the source code you will be able to understand it.

Structure

/ (root)
| assets/      # for eventual assets 
| config/      # where all config files are placed
| controllers/ # where your api controllers should be
| models/      # where data models should be placed 
| seed/        # here are the FW core 
| ----/ libraries/ 
| .htaccess    # it uses mod_rewrite from Apache
| index.php    # where everything starts ...

Support

The framework, as well as this readme file, is on constant evolution.

If you find something wrong, or need some support, feel free to open an issue on github ( here ).

Feel free to contribute or request! Send me your pull requests.

I'm gonna reply as soon as possible.


  Files folder image Files  
File Role Description
Files folder imageassets (1 file)
Files folder imageconfig (3 files)
Files folder imagecontrollers (2 files)
Files folder imagemodels (2 files)
Files folder imageseed (6 files, 1 directory)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files  /  assets  
File Role Description
  Accessible without login Plain text file index.html Data Auxiliary data

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file index.html Data Auxiliary data
  Accessible without login Plain text file routes.php Conf. Configuration script
  Accessible without login Plain text file settings.php Conf. Configuration script

  Files folder image Files  /  controllers  
File Role Description
  Accessible without login Plain text file index.html Data Auxiliary data
  Plain text file index.php Class Class source

  Files folder image Files  /  models  
File Role Description
  Accessible without login Plain text file index.html Data Auxiliary data
  Plain text file sample.php Class Class source

  Files folder image Files  /  seed  
File Role Description
Files folder imagelibraries (5 files)
  Plain text file controller.php Class Class source
  Accessible without login Plain text file index.html Data Auxiliary data
  Accessible without login Plain text file loader.php Aux. Auxiliary script
  Plain text file model.php Class Class source
  Plain text file nucleos.php Class Class source
  Plain text file router.php Class Class source

  Files folder image Files  /  seed  /  libraries  
File Role Description
  Plain text file http.php Class Class source
  Accessible without login Plain text file index.html Data Auxiliary data
  Plain text file logger.php Class Class source
  Plain text file rcurl.php Class Class source
  Plain text file rmysql.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:385
This week:1
All time:6,688
This week:560Up