Rest

概要

APIでのパラメータ返却用に使われるようなXMLやJSON形式のデータを簡単に作成できる。

ビューは定義不要である


イメージ

拡張子をXMLに指定した場合


拡張子をJSONに指定した場合


コントローラー定義

<?php
 
// サンプルコントローラー(Rest)
class Controller_Sample09 extends Controller_Rest
{
	public function get_list()
	{
 
		$result = array(
			'foo' => "hogehog1",
			'baz' => array(
						1
					, 	50
					, 	219
				),
			'empty' => null
        );
 
		// 返却
		$this->response($result);
	}
	public function get_data()
	{
 
		$result = array(
			'foo' => "aaaaaaaaaaa",
			'baz' => array(
						1
					, 	50
					, 	219
				),
			'empty' => null
        );
 
		// 返却
		$this->response($result);
	}
}
 
 

メソッド名

get_xxxと指定することで"xxx"の部分がactionメソッドと定義できる




最終更新:2013年05月22日 23:41