【php】hyperf笔记-路由注解 发表于 2020-02-04 | 更新于 2020-04-10 | 分类于 php | 评论数: | 阅读次数: 1 什么是路由注解? 路由注解是写在类或方法上的,用于的绑定方法和UR并配置请求方式。 2 路由前缀1234567891011121314151617181920212223242526<?phpdeclare(strict_types=1);namespace App\Controller;...use Hyperf\HttpServer\Annotation\AutoController;/** * @AutoController(prefix="/users") * */class IndexController extends AbstractController{ public function index() { $user = $this->request->input('user', 'Hyperf'); $method = $this->request->getMethod(); return [ 'method' => $method, 'message' => "Hello {$user}.", ]; }... GET请求index方法的链接为/users。 路由如果要使用注解的方式,在不配置前缀的前提下, 则心命名空间加类名为URI前缀. 坚持原创技术分享,您的支持将鼓励我继续创作! 打赏 微信支付 支付宝