search
HomePHP FrameworkThinkPHPthinkphp5 integrates Swagger-PHP (pitfall)

The following is the tutorial column of thinkphp to introduce thinkphp5 integrated Swagger-PHP (pitfall). I hope it will be helpful to friends in need!

thinkphp5 integrates Swagger-PHP (pitfall)

In the process of learning Swagger, I found that most of the information on the Internet is not particularly complete, so I specially posted a post to write down my troubleshooting process, hoping to be helpful to everyone.

1. Install swagger-php2.0

(Note: I downloaded swagger-php2.0, this article is for swagger-php2.0)

composer require zircote/swagger-php: 2.0.*

2. Download swagger-ui

Go to the swagger-ui official website to download the static page, and put the static page in the thinkphp framework directory, such as the public directory.

https://swagger.io/tools/swagger-ui/

3. The thinphp framework introduces swagger-php and generates the swagger.json file

use Swagger\Annotations as SWG;
class Index
{
public function index()
{
$swagger=\Swagger\scan(__DIR__);
$res=$swagger->saveAs('./swagger.json');
}

4. Document comment section

/**
* @SWG\Swagger(
* schemes={"http"},
* host="www.tp.com.cn/",
* basePath="/",
* @SWG\Info(
* title="API文档",
* version="1.0.0",
* )
* ),
*/

For detailed instructions on the use of Swgger-php, please visit

https://www.kancloud.cn/chengguang/swagger-php#/catalog

The above is the detailed content of thinkphp5 integrates Swagger-PHP (pitfall). For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool