swagger是java的一個接口調試工具,phper模仿他寫了php-swagger
- github:https://github.com/zircote/swagger-php
- composer安裝
composer require zircote/swagger-php
我用的tp5.0,打開項目主目錄, 找到可執行文件openapi,也可以在Examples中找到例子,照着寫就可以了
- 生成yaml指令
- 我在主目錄的docs-dev中寫編譯前的注釋文件,在public/docs中存放編譯后的yaml文件
php ./vendor/zircote/bin/openapi ./docs-dev/ -o ./public/docs
- 使用swagger-ui
github:https://github.com/swagger-api/swagger-ui
可以通過npm導入模塊,我直接用的github克隆下來使用
cd public git clone https://github.com/swagger-api/swagger-ui
克隆完成后,找到index.html,配置yaml文件路徑
在42行配置好yaml文件路徑即可
然后輸入自己的測試服務器配置好的網址就可以訪問了,例如我的服務器
swagger可以像 postman一樣直接調試哦,非常方便