zhuzixian520 / yii2-api-doc
Generate online api document by code annotation for yii2 easily
Installs: 865
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.4.0
- yiisoft/yii2: ~2.0.0
This package is not auto-updated.
Last update: 2024-11-19 21:29:48 UTC
README
Yii2 Annotations Generate API Document Extension
yii2-api-doc
Generate online api document by code annotation for yii2 easily
Installation
The preferred way to install this extension is through composer.
Either run
composer require --prefer-dist zhuzixian520/yii2-api-doc "*"
or add
"zhuzixian520/yii2-api-doc": "*"
to the require section of your composer.json
file and run
composer install
Usage
Once the extension is installed, simply use it in your code by :
return [ 'modules' => [ 'api_doc' => [ 'class' => 'zhuzixian520\api_doc\Module', 'hostApiDev' => 'http://api-dev.demo.com',//开发环境接口主机地址 'hostApiProd' => 'http://api.demo.com',//生产环境接口主机地址 'hostApiTest' => 'http://api-test.demo.com',//测试环境接口主机地址 'author' => 'Trevor', 'email' => 'service@wangxiankeji.com', 'logo_src' => '/img/logo_64_64.png',//web目录下 'icp_num' => '粤ICP备15025495号', 'copyright_website' => 'http://www.sijiche.com', 'company_start_year' => '2015', ], 'v1' => [ 'class' => 'api\modules\v1\V1Module', ], ], ];
Controller code comments in the API
class PassportController extends yii\rest\Controller { /** * 微信PC网页登录 * @method POST * @token 0 * @param string code 同意授权后的code 是 * @res string token 访问令牌 * @return array */ public function actionLoginByWechatPc(): array {} }
Output
Access the API document address
just like gii or debug,and you can also change the V parameter to switch API versions
http://yourhost/api_doc?v=1
Contact Us
Email:zhuzixian520@126.com