anroots/kohana-hapi

This package is abandoned and no longer maintained. No replacement package was suggested.

HTTP API module for Kohana 3.3

Installs: 216

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 4

Forks: 0

Open Issues: 0

Type:kohana-module

dev-master 2013-03-04 12:42 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:23:27 UTC


README

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