PHPackages                             westhack/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. westhack/think-swagger

ActiveLibrary

westhack/think-swagger
======================

swagger for thinkphp5

1.1.0(5y ago)3342[1 issues](https://github.com/westhack/think-swagger/issues)MITJavaScriptPHP &gt;=5.4.0

Since Sep 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/westhack/think-swagger)[ Packagist](https://packagist.org/packages/westhack/think-swagger)[ Docs](https://github.com/westhack/think-swagger)[ RSS](/packages/westhack-think-swagger/feed)WikiDiscussions master Synced 6d 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 27% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

2082d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2989088?v=4)[helloword](/maintainers/helloword)[@HelloWord](https://github.com/HelloWord)

---

Top Contributors

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

---

Tags

swagger-uithinkthink-swaggertp5

### Embed Badge

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

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

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[darkaonline/swagger-lume

OpenApi or Swagger integration to Lumen

3372.3M3](/packages/darkaonline-swagger-lume)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[light/yii2-swagger

swagger intergation with yii2

154801.6k4](/packages/light-yii2-swagger)

PHPackages © 2026

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