PHP code example of devzyj / yii2-rest
1. Go to this page and download the library: Download devzyj/yii2-rest library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
devzyj / yii2-rest example snippets
// UserController.php
class UserController extends \devzyj\rest\ActiveController
{
public $modelClass = 'app\models\User';
//public $searchModelClass` = 'app\models\UserSearch';
//public $notFoundMessage = 'User not found: `{id}`';
//public $allowedCount = 100;
//public $manyResourcesMessage = 'The number of users requested cannot exceed `{allowedCount}`.';
}
// config.php
return [
'components' => [
'urlManager' => [
......
'rules' => [
[
'class' => 'devzyj\rest\UrlRule',
'controller' => 'user',
//'extraTokens' => ['{account}' => '<account:\\w[\\w]*>'],
]
]
],
],
];