開發者能夠經過plop命令生成各類類型的控制器類(Normal、Restful、View), 如下是示例生成步驟。函數
plop controller
此時控制檯輸出:ui
? controller name please
? controller name please TestNormal ? which type of conroller do you want to create? (Use arrow keys) ❯ Normal Controller Restful Controller View Controller
? which type of conroller do you want to create? Normal Controller ✔ ++ /server/controllers/TestNormalController.js
能夠生成的Controller包括Normal、Restful、View三種類型。rest
用於生成通用的基礎Controller,生成的Controller類會繼承基礎Controller類。code
例如,orm
const Controller = require('../../lib/server/controller/controller'); class TestNormalController extends Controller { } module.exports = TestNormalController;
用於建立基於Restful標準的Controller,生成的類的基類爲RestController,包括了基本的CRUD等函數。server
例如,繼承
const RestController = require('../../lib/server/controller/rest_controller'); class RestRestController extends RestController { index() { } create() { } store() { } show() { } edit() { } update() { } destroy() { } } module.exports = RestRestController;
用於生成基本模板視圖的控制器類,其生成的類的基類爲ViewController。開發
const ViewController = require('../../lib/server/controller/view_controller'); class ViewViewController extends ViewController { view() { } } module.exports = ViewViewController;