Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/theadnan/yii1-api-controller

Template for API controller in Yii
https://github.com/theadnan/yii1-api-controller

api api-rest php php-api yii yii1 yii2

Last synced: 24 days ago
JSON representation

Template for API controller in Yii

Awesome Lists containing this project

README

        

# Yii1 REST API controller
_Template for REST API controller in Yii 1_

## Usage

* Add the *ApiController.php* file to your controllers folder
* Change the `APPLICATION_ID`, and add your models in each action in the switch-case statement (_remove the MyModel example before that_)
* Open the *protected/config/main.php* file and add this to your configuration:
```
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => true,
'rules' => array(
//API rules
array('api/list', 'pattern'=>'api/', 'verb'=>'GET'),
array('api/view', 'pattern'=>'api//', 'verb'=>'GET'),
array('api/update', 'pattern'=>'api//', 'verb'=>'PUT'),
array('api/delete', 'pattern'=>'api//', 'verb'=>'DELETE'),
array('api/create', 'pattern'=>'api/', 'verb'=>'POST'),
),
),
```