####AutoController注解自动生成路由 ``` <?php declare(strict_types=1); namespace App\Controller\User; use Hyperf\HttpServer\Annotation\AutoController; use App\Controller\AbstractController; /** * @AutoController() */ class IndexController extends AbstractController { public function index() { $user = $this->request->input('user', 'Hyperf'); return [ 'method' => $this->request->getMethod(), 'message' => "Hello5 {$user}.", ]; } } ``` >对应的路由地址为`user/index/index` ####AutoController自定义路由前缀 ``` <?php declare(strict_types=1); namespace App\Controller\User; use Hyperf\HttpServer\Annotation\AutoController; use App\Controller\AbstractController; /** * @AutoController(prefix="test") */ class IndexController extends AbstractController { public function index() { $user = $this->request->input('user', 'Hyperf'); return [ 'method' => $this->request->getMethod(), 'message' => "Hello5 {$user}.", ]; } } ``` >对应的路由地址为`test/index/index` 非特殊说明,本文版权归秦官人所有,转载请注明出处. 0 本文标题: hyperf AutoController路由定义 延伸阅读 上一篇: hyperf热更新 下一篇: hyperf Controller注解定义路由的几种方式 发表评论 说点什么吧 | 0评论 最新 最早 还没有评论,快来抢沙发吧!