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

ActiveLibrary[API Development](/categories/api)

sadi01/yii2-swagger
===================

Swagger UI v3 intergation with yii2

1.0.1(3y ago)02051MITPHP

Since Nov 13Pushed 3y agoCompare

[ Source](https://github.com/Sadi01/yii2-swagger)[ Packagist](https://packagist.org/packages/sadi01/yii2-swagger)[ RSS](/packages/sadi01-yii2-swagger/feed)WikiDiscussions master Synced 1mo ago

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

Yii2 Swagger Module
===================

[](#yii2-swagger-module)

This module integrate [swagger-php](https://github.com/zircote/swagger-php) and [swagger-ui v3](https://github.com/swagger-api/swagger-ui).

[![Latest Stable Version](https://camo.githubusercontent.com/d756888956676f93078600d1297b9684a4ec092739fada1d8fd435e33c8b69ed/68747470733a2f2f706f7365722e707567782e6f72672f69676e6174656e6b6f766e696b6974612f796969322d737761676765722f762f737461626c65)](https://packagist.org/packages/ignatenkovnikita/yii2-swagger)[![Total Downloads](https://camo.githubusercontent.com/e3fb84503bc80ece0aeb228e453385e7ce5439929a7b95d7943fb13a15ac56e2/68747470733a2f2f706f7365722e707567782e6f72672f69676e6174656e6b6f766e696b6974612f796969322d737761676765722f646f776e6c6f616473)](https://packagist.org/packages/ignatenkovnikita/yii2-swagger)[![Latest Unstable Version](https://camo.githubusercontent.com/3fa1e133a9c7933be20fd52e63b8e1474fa0448af90d29be360936e587aac802/68747470733a2f2f706f7365722e707567782e6f72672f69676e6174656e6b6f766e696b6974612f796969322d737761676765722f762f756e737461626c65)](https://packagist.org/packages/ignatenkovnikita/yii2-swagger)[![License](https://camo.githubusercontent.com/3051124dd74ed0cb952d7286648396d5ccb4d8558fe433ab68454dd720d4d3ad/68747470733a2f2f706f7365722e707567782e6f72672f69676e6174656e6b6f766e696b6974612f796969322d73656e6470756c73652f6c6963656e7365)](https://packagist.org/packages/ignatenkovnikita/yii2-swagger)

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

[](#installation)

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

Either run

```
php composer.phar require sadi01/yii2-swagger:dev-master

```

or add

```
"sadi01/yii2-swagger": "dev-master"

```

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

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

You set url, where locate json file OR set path for scan

```
'modules' => [
      ...
      'swagger' => [
            'class' => \sadi01\swagger\Module::class,
        //  'url' => 'http://petstore.swagger.io/v2/swagger.json',
            'path' => '@frontend/modules/api',
            // disable page with your logic
            'isDisable' => function () {
                return false;
            },
            // replace placeholders in swagger content
            'afterRender' => function ($content) {
                $content = str_replace('{{host}}', 'http://example.com', $content);
                $content = str_replace('{{basePath}}', '/api/v1', $content);
                return $content;
            }
       ]
        ...
    ],
```

Now you open yourdomain.com/swagger and see API documentation

Example Module

```
/**
 * Class Module Api
 *
 *
 * @SWG\Swagger(
 *     basePath="{{basePath}}",
 *     host="{{host}}",
 *     schemes={"http"},
 *     @SWG\Info(
 *         version="1.0",
 *         title="Example API",
 *         @SWG\Contact(name="Example", url="http://example.ru"),
 *     ),
 *     @SWG\Definition(
 *         definition="Error",
 *         required={"code", "message"},
 *         @SWG\Property(
 *             property="code",
 *             type="integer",
 *             format="int32"
 *         ),
 *         @SWG\Property(
 *             property="message",
 *             type="string"
 *         )
 *     )
 * )
 */
```

Example controller

```
/**
     * @SWG\Post(
     *    path = "/user-device/register",
     *    tags = {"user-device"},
     *    operationId = "userDevice",
     *    summary = "Регистрация устройства",
     *    description = "Регистрация устройства",
     *    produces = {"application/json"},
     *    consumes = {"application/json"},
     *	@SWG\Parameter(
     *        in = "body",
     *        name = "body",
     *        description = "Тело запроса",
     *        required = true,
     *        type = "string",
     *      @SWG\Schema(ref = "#/definitions/UserDeviceForm")
     *    ),
     *	@SWG\Response(response = 200, description = "success")
     *)
     * @throws HttpException
     */
```

Example form

```
/**
 * @SWG\Definition(
 *      definition="UserDeviceForm",
 *      required={"uuid", "token", "os", "json"},
 *      @SWG\Property(
 *          property="uuid",
 *          type="string",
 *          description="UUID устройства",
 *          example="e3243"
 *      ),
 *      @SWG\Property(
 *          property="token",
 *          type="string",
 *          description="token для Google Fire Base",
 *          example="e3243"
 *      ),
 *      @SWG\Property(
 *          property="os",
 *          type="string",
 *          description="os устройства android|ios",
 *          example="ios"
 *      ),
 *      @SWG\Property(
 *          property="json",
 *          type="string",
 *          description="json достпные параметры устройства, название модели, версия ОС и др",
 *          example=""
 *      )
 * )
 */
```

### TODO

[](#todo)

- add cache
- add customization

Donate
------

[](#donate)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](http://paypal.me/ignatenkovnikita)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% 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 ~1 days

Total

2

Last Release

1276d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0bba5660903294a7550aa697b888fd0810c2493097c079170f98a5f18cc1aada?d=identicon)[Sadi01](/maintainers/Sadi01)

---

Top Contributors

[![ignatenkovnikita](https://avatars.githubusercontent.com/u/4436320?v=4)](https://github.com/ignatenkovnikita "ignatenkovnikita (33 commits)")[![Sadi01](https://avatars.githubusercontent.com/u/8774917?v=4)](https://github.com/Sadi01 "Sadi01 (3 commits)")

---

Tags

apiswaggeryii2extensionrestfuldocument

### Embed Badge

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

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

###  Alternatives

[light/yii2-swagger

swagger intergation with yii2

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

Swagger UI v3 intergation with yii2

128.0k](/packages/ignatenkovnikita-yii2-swagger)[dotzero/yii2-amocrm

Расширение для Yii Framework 2 реализующее клиент для работы с API amoCRM

1639.7k](/packages/dotzero-yii2-amocrm)

PHPackages © 2026

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