cshaptx4869 / webman-annotation
webman 注解插件
v1.0.0
2021-12-02 13:17 UTC
Requires
- doctrine/annotations: ^1.13
Requires (Dev)
- workerman/webman: ^1.0
This package is auto-updated.
Last update: 2024-09-29 06:03:15 UTC
README
前言
webman 注解插件。已实现功能
- 路由注解
安装
composer require cshaptx4869/webman-annotation
配置
config/route.php
文件添加如下代码:
<?php use Fairy\AnnotationScanner; $scanner = new AnnotationScanner(); $scanner->registerRoute();
示例
<?php namespace app\controller; use Fairy\Annotation\Route; use support\Request; class Index { /** * 通过get或者post方式请求 /json 即可访问到当前控制器方法 * @Route(url="/json", method="GET") */ public function json(Request $request) { return json(['code' => 0, 'msg' => 'ok']); } }
IDE 注解插件支持
一些IDE已经提供了对注释的支持,推荐安装,以便提供注解语法提示
- Eclipse 通过 Symfony2 插件
- PHPStorm 通过 PHP 注解插件 或 Symfony2 插件