<img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?event=init&amp;tid=2612994575055&amp;pd[em]=<hashed_email_address>&amp;noscript=1">
Skip to content
    AdminOct 2, 2023 6:51:02 PM< 1 min read

    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.

    L5Swagger\L5SwaggerServiceProvider::class,

    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 https://mywebsite.com/api/documentation.

    Click here to create Laravel Swagger API

    Read laravel swagger documentation here.

    COMMENTS

    RELATED ARTICLES