japi JApi, short for JSON API, is an action handler for Yii.

  1. Requirements
  2. Usage
  3. Resources

JApi maps requests in the form ?r=controller/japu&action=method to controller->japiMethod. Then, anything returned from japiMethod is encoded in JSON and sent to the client. Parameters in the function are mapped to _GET varibles. JApi follows the requirments of the parameters, such as optional and required.


I am have used it on Yii 1.1.7 and 1.1.10, may work on others as well


Download and place JApi.php into APPROOT/protected/components

Then in ExampleController.php

class ExampleController extends Controller
	public function japiTest($required,$optional="abc")
		return array('r'=>$required,'o'=>$optional);
	public function actions()
		return array(

Request: /?r=example/japi&action=test&required=text
Returns: {'r':'text','o':'abc'}

Request: /?r=example/japi&action=test&required=text&optional=text2
Returns: {'r':'text','o':'text2'}

Request: /?r=example/japi&action=test
Returns: 400 Malformed Request

You can mix standard actions and JApi actions into one controller


1 0
Yii Version: 1.1
License: MIT
Category: Web Service
Developed by: mrkmg
Created on: May 11, 2012
Last updated: 11 years ago

Related Extensions