frontend ├─ config │ └ main.php ├─ controllers │ └ BookController.php └─ models └ Book.php
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
'components' => [ 'urlManager' => [ 'enablePrettyUrl' => true, 'enableStrictParsing' => true, 'showScriptName' => false, 'rules' => [ ['class' => 'yii\rest\UrlRule', 'controller' => 'book'], ], ], ],
-- ----------------------------
-- Table structure for book
-- ----------------------------
DROP TABLE IF EXISTS `book`;
CREATE TABLE `book` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` char(50) NOT NULL DEFAULT '',
`num` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of book
-- ----------------------------
INSERT INTO `book` VALUES ('1', 'toefl', '10');
INSERT INTO `book` VALUES ('2', 'ielts', '20');
INSERT INTO `book` VALUES ('3', 'sat', '30');
INSERT INTO `book` VALUES ('4', 'gre', '40');
INSERT INTO `book` VALUES ('5', 'gmat', '50');
namespace frontend\models;
use yii\db\ActiveRecord;
class Book extends ActiveRecord
{
public static function tableName()
{
return 'book';
}
}
namespace frontend\controllers;
use yii\rest\ActiveController;
class BookController extends ActiveController
{
public $modelClass = 'frontend\models\Book';
}
'rules' => [ ['class' => 'yii\rest\UrlRule', 'controller' => 'book', 'pluralize' => false], ],
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有