PHPackages                             niamulhasan/laravel-swagger-ui-generator - 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. niamulhasan/laravel-swagger-ui-generator

ActiveLibrary[API Development](/categories/api)

niamulhasan/laravel-swagger-ui-generator
========================================

A swagger OpenApi Documentation generator for laravel; This package requires no phpDoc comments

711PHP

Since Jan 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nagoriktech/laravel-swagger-ui-generator)[ Packagist](https://packagist.org/packages/niamulhasan/laravel-swagger-ui-generator)[ RSS](/packages/niamulhasan-laravel-swagger-ui-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (1)Used By (0)

Laravel Swagger API Doc Generator - API Doctor.
===============================================

[](#laravel-swagger-api-doc-generator---api-doctor)

A swagger OpenApi Documentation auto generator for laravel. This package **requires no phpDoc or any kind of comments**

 [![niamulhasan](https://camo.githubusercontent.com/8c484f1d4a6d61d58d8d22e749e8d4598fc0c0f69271b70291a365cfa31c050b/68747470733a2f2f6b6f6d617265762e636f6d2f67687076632f3f757365726e616d653d6c61726176656c2d6170692d646f63746f722d73776167676572266c6162656c3d566965777326636f6c6f723d306537356236267374796c653d666c6174)](https://camo.githubusercontent.com/8c484f1d4a6d61d58d8d22e749e8d4598fc0c0f69271b70291a365cfa31c050b/68747470733a2f2f6b6f6d617265762e636f6d2f67687076632f3f757365726e616d653d6c61726176656c2d6170692d646f63746f722d73776167676572266c6162656c3d566965777326636f6c6f723d306537356236267374796c653d666c6174)

[packagist.org/users/niamulhasan/packages/](https://packagist.org/users/niamulhasan/packages/)Motivation
----------

[](#motivation)

When I was trying to generate swagger documentation for my laravel project, I found that all the available packages require you to write phpDoc or other form of comments. I didn't want to write comments for all my routes and controllers. as it is time-consuming and I am lazy. And the documentation gets outdated very quickly creating a maintenance headache and a source of inconsistency. So I decided to create a package that will generate the swagger documentation from the routes and controllers automatically without any form of comments.

Features
--------

[](#features)

- Generates swagger documentation automatically from the routes and controllers.
- No need to write phpDoc or any other form of comments.
- Generates documentation for URL parameters.
- Generates documentation for Request body using the `Form Request` type.

Limitations
-----------

[](#limitations)

- Currently, response documentation is not generated.
- File upload and multipart form data are not supported.

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

[](#installation)

### Step 1: Add these lines to your .env file

[](#step-1-add-these-lines-to-your-env-file)

```
SWAGGER_VERSION=2.0

```

### Step 2: Add the package repository to your composer.json file

[](#step-2-add-the-package-repository-to-your-composerjson-file)

In your projects `composer.json` file,add the following "repositories" section:

```
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/nagoriktech/laravel-swagger-ui-generator"
    }
]
```

Example:

```
{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    //Here is the section
    "repositories": [
      {
        "type": "vcs",
        "url": "https://github.com/nagoriktech/laravel-swagger-ui-generator"
      }
    ],
    "require": {
        "php": "^7.2.5",
        "fideloper/proxy": "^4.0"
    },
    ...
    ...

}
```

### Step 3: Set the minimum stability

[](#step-3-set-the-minimum-stability)

Set the `"minimum-stability": "dev"` in composer.json

### Step 4: Install the package

[](#step-4-install-the-package)

Then run the following command to install the package:

```
composer require niamulhasan/api-doctor-swagger
```

### Step: 5 Add the provider

[](#step-5-add-the-provider)

Add the following line to the `providers` array:

```
NiamulHasan\ApiDoctorSwagger\Providers\ApiDoctorProvider::class,
```

You can find the providers in `config/app.php` file for Laravel 11 it's in the `bootstrap/providers.php` file.

This will register the package's service provider for your project.

### Step 5: Publish the package's config file

[](#step-5-publish-the-packages-config-file)

Run the following command to publish the package's config file:

```
php artisan vendor:publish --provider="NiamulHasan\ApiDoctorSwagger\Providers\ApiDoctorProvider"
```

### Step 6: Turn off CSRF protection for the API routes

[](#step-6-turn-off-csrf-protection-for-the-api-routes)

If you face csrf\_token missmatch issue

```
`protected $except = [
    'api/*'
];`

```

add this in your `app/Http/Middleware/VerifyCsrfToken.php` file

#### For Laravel 11: in `bootstrap/app.php` file

[](#for-laravel-11-in-bootstrapappphp-file)

add this

```
$middleware->validateCsrfTokens(except: ['api/*']);
```

in middleware Like this

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: ['api/*']);
})
```

Usage
-----

[](#usage)

For now this package can generate doc only for **URL parameters** and **Request body**. It will not generate doc for **Query parameters**.

To be able to generate doc for Body parameters you must have to use **Form Request** in your controller method.

### Example

[](#example)

In your controller method:

```
public function filter(CircularFilterRequest $request): array
    {
        return CircularResource::collection(CircularsService::filter($request->job_type, $request->order_by, $request->order, $request->tags))->toArray($request);
    }
```

In your Form Request:

```
class CircularFilterRequest extends FormRequest
{
    public function rules()
    {
        return [
            'order_by' => 'string|nullable|in:created_at,starting_date,deadline',
            'order' => 'string|nullable|in:asc,desc',
            'job_type' => 'string|nullable|in:gov,non-gov',
            'tags' => 'array|nullable',
        ];
    }
}
```

A new route will be added to your project. You can access the swagger documentation by visiting the following url:

```
http://your-project-url/api-docs

```

And the swagger yaml file will be available at:

```
http://your-project-url/swagger-yaml-file-generated

```

Conclusion
----------

[](#conclusion)

This package has been developed for our own needs. I will be adding more features and improvements to it as I need them. Feel free to open an issue or a pull request for bug fixes or new features.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/8df339b896f2dded950e5c2d7a9a23bfb78ab0ef24d922e03ee335a8d7617281?d=identicon)[niamulhasan](/maintainers/niamulhasan)

---

Top Contributors

[![niamulhasan](https://avatars.githubusercontent.com/u/11660121?v=4)](https://github.com/niamulhasan "niamulhasan (16 commits)")[![niamul111](https://avatars.githubusercontent.com/u/123290903?v=4)](https://github.com/niamul111 "niamul111 (10 commits)")[![zihadtechvill](https://avatars.githubusercontent.com/u/95599761?v=4)](https://github.com/zihadtechvill "zihadtechvill (1 commits)")

---

Tags

api-restapidoc-generatorlaravelswagger

### Embed Badge

![Health badge](/badges/niamulhasan-laravel-swagger-ui-generator/health.svg)

```
[![Health](https://phpackages.com/badges/niamulhasan-laravel-swagger-ui-generator/health.svg)](https://phpackages.com/packages/niamulhasan-laravel-swagger-ui-generator)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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