PHPackages                             iseefu/think-swagger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. iseefu/think-swagger

ActiveLibrary[API Development](/categories/api)

iseefu/think-swagger
====================

swagger for thinkphp5

1.1.0(5y ago)014MITJavaScriptPHP &gt;=5.4.0

Since Sep 3Pushed 5y agoCompare

[ Source](https://github.com/Johnandfu/think-swagger)[ Packagist](https://packagist.org/packages/iseefu/think-swagger)[ Docs](https://github.com/westhack/think-swagger)[ RSS](/packages/iseefu-think-swagger/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

think-swagger
=============

[](#think-swagger)

The ThinkPHP5 swagger Swagger composer模块

安装
--

[](#安装)

### 一、执行命令安装

[](#一执行命令安装)

```
composer require westhack/think-swagger

```

或者

### 二、require安装

[](#二require安装)

```
"require": {
        "westhack/think-swagger":"*"
},

```

或者

### 三、autoload psr-4标准安装

[](#三autoload-psr-4标准安装)

1. 进入 vendor/westhack 目录 (没有 westhack 目录 mkdir westhack)
2. git clone
3. 修改 git clone 下来的项目名称为 think-swagger
4. 添加下面配置

```
    "autoload": {
           "psr-4": {
               "westhack\\swagger\\": "vendor/westhack/think-swagger/src"
           },
           "files": [
               "vendor/westhack/think-swagger/src/route.php"
           ]
       },

```

5. php composer.phar update

使用
--

[](#使用)

#### 添加配置文件

[](#添加配置文件)

1. 默认配置在 config 下面的 swagger.php
2. 需要自己的配置将 config 下面的 swagger.php 复制到 extra 目录下面（或者通过下面 console 添加配置文件）

#### 使用方法

[](#使用方法)

#### 初始化项目资源

[](#初始化项目资源)

> 在项目目录下面找到 command.php 添加控制台添加下面配置

```
    return [
        'westhack\swagger\SwaggerAssetRegister'
    ];

```

> 执行 console 命令初始化 assets 资源

```
    php think swaggerAssetRegister   ## 默认资源目录
    php think swaggerAssetRegister --path /public/static   ## 绝对路径
    php think swaggerAssetRegister --path swagger/ui   ## 默认资源目录下面的路径

```

> 执行 console 命令初始化 config 配置

```
    php think swaggerAssetRegister --config y   ## 初始化 config 配置

```

#### 访问

[](#访问)

```
    http://你的域名/index.php?s=swagger ## swagger ui
    http://你的域名/index.php?s=swagger/api ##  swagger json
    http://你的域名/index.php?s=swagger/api&clear-cache ## 清除缓存（如果开启缓存）

```

#### 在php文件中添加注释

[](#在php文件中添加注释)

```
/**
 * @SWG\Info(title="My First API", version="0.1")
 */

/**
 * @SWG\Get(
 *     path="/api/resource.json",
 *     @SWG\Response(response="200", description="An example resource")
 * )
 */

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2128d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a84e5da4f68ce16b8fe442389d2d65d9c7c63a3e45b1ce714549f5897d4c9190?d=identicon)[iseefu](/maintainers/iseefu)

---

Top Contributors

[![Johnandfu](https://avatars.githubusercontent.com/u/16249682?v=4)](https://github.com/Johnandfu "Johnandfu (10 commits)")[![westhack](https://avatars.githubusercontent.com/u/11475545?v=4)](https://github.com/westhack "westhack (7 commits)")

### Embed Badge

![Health badge](/badges/iseefu-think-swagger/health.svg)

```
[![Health](https://phpackages.com/badges/iseefu-think-swagger/health.svg)](https://phpackages.com/packages/iseefu-think-swagger)
```

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

3.0k37.6M133](/packages/darkaonline-l5-swagger)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.4k67.4M263](/packages/nelmio-api-doc-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M572](/packages/shopware-core)[tangwei/apidocs

A swagger library for Hyperf.

53137.0k8](/packages/tangwei-apidocs)[hyperf/swagger

A swagger library for Hyperf.

20371.1k7](/packages/hyperf-swagger)[pimcore/studio-backend-bundle

Pimcore Studio Backend Bundle

20203.9k22](/packages/pimcore-studio-backend-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
