### 一、Composer安裝
本小冊針對swagger-php2.0
```
composer require zircote/swagger-php:2.0.*
```
安裝完成后,我們就可以編寫注釋了生成json文件了。
在控制器index中填入以下內容生成swagger.json
```
use Swagger\Annotations as SWG;
class Index
{
public function index()
{
$swagger=\Swagger\scan(__DIR__);
$res=$swagger->saveAs('./swagger.json');
}
}
```
注釋部分:
```
/**
* @SWG\Swagger(
* schemes={"http"},
* host="www.tp.com.cn/",
* basePath="/",
* @SWG\Info(
* title="API文檔",
* version="1.0.0",
* )
*/)
```
在瀏覽器中輸入地址:
[www.tp.com.cn/]()