thinkphp怎么注釋路由

thinkphp注釋路由的方法:1、打開相應的tp文件;2、通過“/* @route(‘test’)*/class Test extends Controller{public function index(){return ‘index’;…}”方式注解資源路由即可。

thinkphp怎么注釋路由

本教程操作環境:Windows10系統、thinkphp5版、Dell G3電腦。

thinkphp怎么注釋路由?

代碼如下:

/**注解資源路由 ?*?@route('test') ?*/ class?Test?extends?Controller{ ????public?function?index(){//test????get ????????return?'index'; ????} ????public?function?create(){//test/create???get ????????return?'create'; ????} ????public?function?save(){//test?????post ????????return?'save'; ????} ????public?function?read(){//test/:id???get ????????return?'read'; ????} ????public?function?edit(){//test/:id/edit?????get ????????return?'edit'; ????} ????/**?如果你不想通過資源方式put訪問,可以通過注解路由get方式訪問 ?????*?@route('update','get') ????*/ ????public?function?update(){//test/:id??????put???資源路由put方式訪問 ????????return?'update'; ????} ????/**? ?????*?@route('delete','get') ????*/ ????public?function?delete(){//test/:id??????delete ????????return?'delete'; ????} }

推薦學習:《thinkPHP視頻教程

立即學習PHP免費學習筆記(深入)”;

以上就是

? 版權聲明
THE END
喜歡就支持一下吧
點贊14 分享