ThinkPHP支持使用注解方式定义路由(也称为注解路由),如果需要使用注解路由需要安装额外的扩展:
composer require topthink/think-annotation
然后只需要直接在控制器类的方法注释中定义,例如:
<?phpnamespace app\controller;use think\annotation\Route;class Index{