TP6.0 命令行生成類庫文件

作者:辰風(fēng)沐陽 閱讀:2030 發(fā)布時間:2020-08-01 上次更新:2020-08-01

1. 生成控制器


  1. // 默認(rèn)生成資源控制器,有七個方法資源操作方法
  2. // index、create、save、read、edit、update、delete
  3. php think make:controller Blog
  4. // 創(chuàng)建多級控制器
  5. php think make:controller user/Blog
  6. // 創(chuàng)建index應(yīng)用下的Blog控制器
  7. php think make:controller index@Blog
  8. // 創(chuàng)建多級控制器
  9. php think make:controller index@user/Profile
  10. // 如果僅僅生成空的控制器則可以加上參數(shù) --plain
  11. php think make:controller User --plain
  12. // 如果只是用于接口開發(fā),可以使用參數(shù) --api
  13. // index、save、read、update、delete
  14. // 默認(rèn)提供5個操作方法,和資源控制器相比少了 create 和 edit 方法
  15. php think make:controller User --api

2. 生成模型


  1. php think make:model Blog
  2. php think make:model index@Blog
  3. php think make:model index@user/Profile

3. 生成驗證器


  1. php think make:validate User
  2. php think make:validate admin@User
  3. php think make:validate admin@user/Address

4. 生成中間件


注意:命令行不支持直接在應(yīng)用下創(chuàng)建中間件

  1. php think make:middleware Login
  2. php think make:middleware user/Login

標(biāo)簽: ThinkPHP TP6.0