Skip to content

Getting Started

DerManoMann edited this page Nov 9, 2026 · 1 revision

Installation

Install L5-Swagger with Composer:

composer require darkaonline/l5-swagger

The service provider is registered through Laravel's package discovery, so there is nothing to add to config/app.php.

Generating the documentation

L5-Swagger builds the documentation from the OpenAPI attributes of zircote/swagger-php in your code. By default, it scans the app directory. For an example, see L5-Swagger's own test fixtures, or swagger-php's petstore example.

Once the attributes are in place, generate the documentation:

php artisan l5-swagger:generate

The documentation is then available at /api/documentation.

During development, set L5_SWAGGER_GENERATE_ALWAYS=true in your .env file to regenerate the documentation on every request instead.

Configuration

L5-Swagger works with its defaults. To change them, publish the config file and the views:

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

Every option is described on the Configuration page.

Note: the documentation routes have no middleware by default, so the documentation is public. To restrict access in production, see routes.middleware on the Configuration page.

Versions

L5-Swagger Laravel PHP swagger-php
11.x 11.44+, 12.1+, 13 8.2+ 6.3.1+
10.x 11.44+, 12.1+ 8.2+ 6
9.x 11, 12 8.2+ 5
8.x 7, 8.40+, 9, 10, 11 7.2+ 3.2+, 4
7.x 7 7.2+ 2, 3
6.x 6 7.2+ 2, 3
5.8.x 5.6 to 5.8 7.1.3+ 2, 3
4.x and older 5.4 and older 5.4+ 2

composer require darkaonline/l5-swagger installs the latest L5-Swagger that supports your Laravel version. To install an older one, add the version, for example composer require "darkaonline/l5-swagger:^8.6".

When moving to a new major version, see the Migration Guides and the Change Log.

Clone this wiki locally