search
HomePHP FrameworkThinkPHPHow to annotate routes in thinkphp

How to annotate routes in thinkphp

Dec 20, 2022 am 09:56 AM
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.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools