PHPackages                             gish94/yii2-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. gish94/yii2-swagger

ActiveLibrary[API Development](/categories/api)

gish94/yii2-swagger
===================

swagger intergation with yii2

1.0.6.1(8y ago)024MITPHP

Since Dec 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/gish94/yii2-swagger)[ Packagist](https://packagist.org/packages/gish94/yii2-swagger)[ RSS](/packages/gish94-yii2-swagger/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (3)Versions (14)Used By (0)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

Yii2 Swagger Extension
======================

[](#yii2-swagger-extension)

This is fork from lichunqiang/yii2-swagger with swagger-ui 3.4.5 support. [swagger-php](https://github.com/zircote/swagger-php) intergation with yii2.

Integration [swagger-ui](https://github.com/swagger-api/swagger-ui) with [swagger-php](https://github.com/zircote/swagger-php).

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist light/yii2-swagger "~1.0.4" --dev

```

or add

```
"light/yii2-swagger": "~1.0.4"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Configure two action as below:

```
public function actions()
{
    return [
        //The document preview addesss:http://api.yourhost.com/site/doc
        'doc' => [
            'class' => 'light\swagger\SwaggerAction',
            'restUrl' => \yii\helpers\Url::to(['/site/api'], true),
        ],
        //The resultUrl action.
        'api' => [
            'class' => 'light\swagger\SwaggerApiAction',
            //The scan directories, you should use real path there.
            'scanDir' => [
                Yii::getAlias('@api/modules/v1/swagger'),
                Yii::getAlias('@api/modules/v1/controllers'),
                Yii::getAlias('@api/modules/v1/models'),
                Yii::getAlias('@api/models'),
            ],
            //The security key
            'api_key' => 'balbalbal',
        ],
    ];
}

```

> For security, you can config api key for protection.

Caching
-------

[](#caching)

```
public function actions()
{
    return [
        // ...
        'api' => [
            // ...
            'cache' => 'cache',
            'cacheKey' => 'api-swagger-cache', // default is 'api-swagger-cache'
        ],
    ];
}

```

#### Clear cache

[](#clear-cache)

Access clear cache url `YOUR_API_URL?clear-cache` or `YOUR_API_URL?api_key=YOUR_API_KEY&clear-cache`

Example: `curl 'http://localhost/v1/swagger/api?clear-cache'`

you will see: `Succeed clear swagger api cache.`

License
-------

[](#license)

[![MIT](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

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

Every ~61 days

Recently: every ~71 days

Total

13

Last Release

3120d ago

Major Versions

0.2.3 → 1.0.02016-01-10

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8583056?v=4)[Ashot Kirakosyan](/maintainers/gish94)[@gish94](https://github.com/gish94)

---

Top Contributors

[![lichunqiang](https://avatars.githubusercontent.com/u/2433916?v=4)](https://github.com/lichunqiang "lichunqiang (28 commits)")[![dcb9](https://avatars.githubusercontent.com/u/3984347?v=4)](https://github.com/dcb9 "dcb9 (3 commits)")[![clh021](https://avatars.githubusercontent.com/u/1754391?v=4)](https://github.com/clh021 "clh021 (1 commits)")[![gish94](https://avatars.githubusercontent.com/u/8583056?v=4)](https://github.com/gish94 "gish94 (1 commits)")[![Kolyunya](https://avatars.githubusercontent.com/u/2682768?v=4)](https://github.com/Kolyunya "Kolyunya (1 commits)")

---

Tags

swaggeryii2extensionrestfuldocument

### Embed Badge

![Health badge](/badges/gish94-yii2-swagger/health.svg)

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

###  Alternatives

[light/yii2-swagger

swagger intergation with yii2

153835.2k4](/packages/light-yii2-swagger)[ignatenkovnikita/yii2-swagger

Swagger UI v3 intergation with yii2

128.1k](/packages/ignatenkovnikita-yii2-swagger)

PHPackages © 2026

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