Skip to content

Commit 209f55f

Browse files
authored
Document enhancement and made compatible with Laravel 11
1 parent 9d699bc commit 209f55f

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

README.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
# API Doctor Swagger for Laravel (Auto Generator).
2-
A swagger OpenApi Documentation generator for laravel. This package **requires no phpDoc comments**
2+
A swagger OpenApi Documentation auto generator for laravel. This package **requires no phpDoc or any kind of comments**
33
<p align="left"> <img src="https://komarev.com/ghpvc/?username=laravel-api-doctor-swagger&label=Views&color=0e75b6&style=flat" alt="niamulhasan" /> </p>
44

5-
## About
6-
All other swagger packages require you to write phpDoc comments. This package is different. It will generate swagger documentation from your routes and controllers.
5+
## Motivation
6+
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.
7+
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.
8+
So I decided to create a package that will generate the swagger documentation from the routes and controllers automatically without any form of comments.
9+
10+
## Features
11+
- Generates swagger documentation automatically from the routes and controllers.
12+
- No need to write phpDoc or any other form of comments.
13+
- Generates documentation for URL parameters.
14+
- Generates documentation for Request body using the `Form Request` type.
15+
16+
## Limitations
17+
- Currently, response documentation is not generated.
18+
- File upload and multipart form data are not supported.
19+
720

821
## Installation
922
### Step 1: Add these lines to your .env file
@@ -46,32 +59,45 @@ Example:
4659
}
4760
```
4861

62+
### Step 3: Set the minimum stability
4963
Set the `"minimum-stability": "dev"` in composer.json
5064

51-
### Step 3: Install the package
65+
### Step 4: Install the package
5266
Then run the following command to install the package:
5367
```bash
5468
composer require niamulhasan/api-doctor-swagger
5569
```
56-
### Step: 4 Edit your `config/app.php` file (Laravel 11 `bootstrap/providers.php`)
70+
### Step: 5 Add the provider
5771
Add the following line to the `providers` array:
5872
```php
5973
NiamulHasan\ApiDoctorSwagger\Providers\ApiDoctorProvider::class,
6074
```
75+
76+
You can find the providers in `config/app.php` file
77+
for Laravel 11 it's in the `bootstrap/providers.php` file.
78+
6179
This will register the package's service provider for your project.
6280

6381
### Step 5: Publish the package's config file
6482
Run the following command to publish the package's config file:
83+
```bash
84+
php artisan vendor:publish --provider="NiamulHasan\ApiDoctorSwagger\Providers\ApiDoctorProvider"
85+
```
6586

66-
### Step 6: If you face csrf_token missmatch issue
87+
### Step 6: Turn off CSRF protection for the API routes
88+
If you face csrf_token missmatch issue
6789

6890
`protected $except = [
6991
'api/*'
7092
];`
71-
add this in your `app/Http/Middleware/VerifyCsrfToken.php`
93+
add this in your `app/Http/Middleware/VerifyCsrfToken.php` file
7294

73-
#### For Laravel 11: in `bootstrap/app.php`
74-
add `$middleware->validateCsrfTokens(except: ['api/*']);` in middleware
95+
#### For Laravel 11: in `bootstrap/app.php` file
96+
add this
97+
```php
98+
$middleware->validateCsrfTokens(except: ['api/*']);
99+
```
100+
in middleware
75101
Like this
76102
```php
77103
->withMiddleware(function (Middleware $middleware) {
@@ -124,3 +150,8 @@ http://your-project-url/swagger-yaml-file-generated
124150

125151
## Conclusion
126152
This package is being developed for my own projects. I will be adding more features to it as I need them. If you have any suggestions or find any bug please feel free to open an issue or a pull request.
153+
154+
## Conclusion
155+
This package has been developed for our own needs.
156+
I will be adding more features and improvements to it as I need them.
157+
Feel free to open an issue or a pull request for bug fixes or new features.

0 commit comments

Comments
 (0)