anroots/kohana-hapi 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

anroots/kohana-hapi

Composer 安装命令:

composer require anroots/kohana-hapi

包简介

HTTP API module for Kohana 3.3

README 文档

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

统计信息

  • 总下载量: 216
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-01-28