Home>Article>PHP Framework> How to annotate routes in thinkphp
Thinkphp method to annotate routing: 1. Open the corresponding tp file; 2. Pass "/* @route('test')*/class Test extends Controller{public function index(){return 'index' ;...}" method to annotate resource routing.
#The operating environment of this tutorial: Windows 10 system, thinkphp version 5, Dell G3 computer.
How to annotate routes in thinkphp?
The code is as follows:
/**注解资源路由 * @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'; } }
Recommended learning: "thinkPHP Video Tutorial"
The above is the detailed content of How to annotate routes in thinkphp. For more information, please follow other related articles on the PHP Chinese website!