Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/theadnan/yii1-api-controller
- Owner: TheAdnan
- Created: 2017-10-10T10:35:10.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-10T11:19:38.000Z (about 7 years ago)
- Last Synced: 2024-10-24T15:40:35.704Z (2 months ago)
- Topics: api, api-rest, php, php-api, yii, yii1, yii2
- Language: PHP
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
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'),
),
),
```