Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

anroots/kohana-hapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kohana HAPI

HyperMedia Application Programming Interface - A Kohana module to use as a framework for building HTTP APIs.

Screenshot of a HTTP response

In development. Do not use. It is expected that the major (backwards incompatible) versions will be increased rapidly.

What it is

  • Framework for adding API support to your Kohana project
  • Unfinished
  • Rather strict than general-purpose

What it is not

  • RESTful - Well, a bit, but missing [level three of the API maturity model](http://www.crummy .com/writing/speaking/2008-QCon/act3.html)
  • Scalable and optimized - mean for one server, one client approach where client is under vendor control
  • Tested

Installation

  • Clone and enable the module. Use a git submodule, download the zip or add a Composer dependency
  • Add a route to the API controller:
<?php
Route::set(
	'api',
	'api(/<controller>(/<id>(/<action>)))'
)
	->defaults(
	array(
		'directory'  => 'API/V1/',
		'controller' => 'About',
		'action'     => 'index'
	)
);
  • Create APPPATH/classes/Controller/API/V1/Main.php - extends Controller_HAPI
  • Create APPPATH/classes/Controller/API/V1/About.php - extends Controller_API_V1_Main
  • In the action_index, write:
<?php
$this->hapi(['about' => 'Hello, world']);
  • Make a HTTP GET query to `BASE_URL/api/v1/about

TODO

  • Remove some of the hardcoded values to support not only JSON
  • Document code, wiki, gh-pages
  • Improve architecture
  • Improve API semantics: provide meaningful error and status messages in response body
  • Work towards achieving REST

Releases

No releases published

Packages

No packages published

Languages