<?php namespace app\controllers; use yii\rest\ActiveController; class UserController extends ActiveController { public $modelClass = 'app\models\MyUser'; } ?>
<?php $params = require(__DIR__ . '/params.php'); $config = [ 'id' => 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'components' => [ 'request' => [ // !!! insert a secret key in the following (if it is empty) - this is //required by cookie validation 'cookieValidationKey' => 'tw511.com', ], 'cache' => [ 'class' => 'yii\caching\FileCache', ], 'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => true, ], 'errorHandler' => [ 'errorAction' => 'site/error', ], 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', // send all mails to a file by default. You have to set // 'useFileTransport' to false and configure a transport // for the mailer to send real emails. 'useFileTransport' => true, ], 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], 'urlManager' => [ 'enablePrettyUrl' => true, 'enableStrictParsing' => true, 'showScriptName' => false, 'rules' => [ ['class' => 'yii\rest\UrlRule', 'controller' => 'user'], ], ],'request' => ['class' => '\yii\web\Request','enableCookieValidation' => false,'parsers' => ['application/json' => 'yii\web\JsonParser',],'cookieValidationKey' => 'Otw511.com2trde1xww-M97_7QvwPo-5yiiBai@#720',],'db' => require(__DIR__ . '/db.php'), ], 'modules' => [ 'admin' => [ 'class' => 'app\modules\hello\Admin', ], ], 'params' => $params, ]; if (YII_ENV_DEV) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', ]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', ]; } return $config; ?>
GET /users ? 進行逐頁讀取所有使用者
HEAD /users ? 顯示使用者列表概述資訊
POST /users ? 建立一個新使用者
GET /users/20 ? 返回使用者ID為 20 的詳細資訊
HEAD /users/20 ? 顯示使用者ID為20的使用者概述資訊
PATCH /users/ 20 和 PUT /users/20 ? 更新使用者ID為20的使用者資訊
DELETE /users/20 ? 刪除使用者ID為20的使用者資訊
OPTIONS /users ? 顯示端點 /users 支援的動詞
OPTIONS /users/20 ? 顯示端點 /users/20 支援的動詞