Create Laravel Swagger API

Swagger provides us tools to create documentation for our apis and shares their definitions with teams, developers or consumers. Here we will create laravel swagger API documentation.

Install the laravel swagger package using the below commands

composer require "darkaonline/l5-swagger"

If facing version issue then use this command

composer require darkaonline/l5-swagger:*

Now open config/app.php and add this line in providers section.


Now publish L5-Swagger’s config and view files with this commands

php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"

To generate the swagger api documentation run

php artisan l5-swagger:generate

We can also set L5_SWAGGER_GENERATE_ALWAYS = true in .env file to autogenerate the api documentation.

Now we can access our api documentation with this url

Click here to create Laravel Swagger API

Read laravel swagger documentation here.