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

ActiveYii2-extension[API Development](/categories/api)

fgh151/yii2-swagger
===================

yii2 swagger files generator

0.0.10(11mo ago)0209Apache-2.0PHPPHP &gt;=8.1.0CI passing

Since May 7Pushed 11mo ago1 watchersCompare

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

READMEChangelog (9)Dependencies (3)Versions (6)Used By (0)

swgger
======

[](#swgger)

Yii2 swagger generator

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist fgh151/yii2-swagger "*"

```

or add

```
"fgh151/yii2-swagger": "*"

```

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

Usage
-----

[](#usage)

1. Add module in config and set dirs with annotations

```
'modules' => [
    'swagger' => [
        'class' => fgh151\swagger\Module::class,
        'sources' => [
            dirname(__DIR__).'/controllers', //here can be aliases, like '@app/controllers'
            dirname(__DIR__).'/models',
        ],
        'schema' => '/api/schema', //optional depend on route config
    ],
],
```

2. Add routes

```
'rules' => [
    '/swagger/doc.json' => 'swagger/swagger/doc',
    '/swagger/ui' => 'swagger/swagger/ui',
],
```

3. Add controller. It can be not useful and has random name, but contain annotations. Example:

```
