thinkphp注解路由

class Test{
    /**
     * @param string $name
     * @route('test/:name','get')//第二个参数中指定请求类型
     * ->http()
     * ->pattern(['name'=>'\d+'])
     * 
     */
    public function index($name){
        echo '你好 '.$name;
    }
}

建议路由定义写在注释最后一段,否则后面需要一个空行
注意在添加路由参数和变量规则的最后不需要加;,并且确保和后面的其它注释之间间隔一个空行。
访问方式:http://localhost/server/public/index.php/test/5654

发布了122 篇原创文章 · 获赞 5 · 访问量 4818

猜你喜欢

转载自blog.csdn.net/weixin_41254345/article/details/104632715