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!
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!

宝塔部署thinkphp5报错的解决办法:1、打开宝塔服务器,安装php pathinfo扩展并启用;2、配置“.access”文件,内容为“RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]”;3、在网站管理里面,启用thinkphp的伪静态即可。

thinkphp5 post得不到值是因为TP5是通过strpos函数在Header的content-type值中查找app/json字符串的,其解决办法就是设置Header的content-type值为app/json即可。

thinkphp5 url重写不行的解决办法:1、查看httpd.conf配置文件中是否加载了mod_rewrite.so模块;2、将AllowOverride None中的None改为All;3、修改Apache配置文件.htaccess为“RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]”保存即可。

thinkphp5获取请求网址的方法:1、使用“\think\Request”类的“$request = Request::instance();”方法获取当前的url信息;2、通过自带的助手函数“$request->url()”获取包含域名的完整URL地址。

去除thinkphp5标题栏icon的方法:1、找到thinkphp5框架public下的favicon.ico文件;2、删除该文件或者选择另一张图片命名改为favicon.ico,并替换原favicon.ico文件即可。

thinkphp5提示控制器不存在的解决办法:1、检查对应的控制器里面的命名空间是否写对,修改为正确的命名空间;2、打开相应的tp文件,修改类名即可。

ThinkPHP5查询昨天数据的方法:1、打开ThinkPHP5相关文件;2、通过表达式“db('table')->whereTime('c_time', 'yesterday')->select();”查询昨天的数据即可。

thinkphp5设置报错提示的方法:1、进入项目根目录下的public文件夹,打开index.php入口文件;2、查看调试模式开关的注释;3、将“APP_DEBUG”常量的值调整为true即可展示错误信息提示。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools
