Home>Article>PHP Framework> How to annotate routes in thinkphp

How to annotate routes in thinkphp

藏色散人
藏色散人 Original
2022-12-20 09:56:27 1017browse

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.

How to annotate routes in thinkphp

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn