scalar/laravel

Render your OpenAPI-based API reference
203,371 67
Install
composer require scalar/laravel
Latest Version:0.2.1
PHP:^8.2||^8.3
License:MIT
Last Updated:Jul 23, 2026
Links: GitHub  ·  Packagist
Maintainer: hanspagel

Scalar for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Use your OpenAPI documents to render modern API references in Laravel

Screenshot of a Laravel-themed API reference

Installation

You can install the package via composer:

composer require scalar/laravel

You can publish the config file with:

php artisan vendor:publish --tag="scalar-config"

Optionally, you can publish the views using

php artisan vendor:publish --tag="scalar-views"

Usage

You’ll need an OpenAPI/Swagger document to render your API reference with Scalar. Here are some packages that help generating those documents:

Once done, you can pass it to Scalar. Just make sure it’s a publicly accessible URL.

<?php

// config/scalar.php

return [
    // …

    'url' => '/openapi.yaml',

    // …
]

Authorization

The Scalar API reference may be accessed via the /scalar route. By default, everyone will be able to access this route. However, within your App\Providers\AppServiceProvider.php file, you can overwrite the gate definition. This authorization gate controls access to Scalar in non-local environments. You are free to modify this gate as needed to restrict access to your documentation:

<?php

namespace App\Providers;

use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Gate::define('viewScalar', function (?User $user) {
            return in_array($user->email, [
                //
            ]);
        });
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions are welcome.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

bbrody/swagger-lume

OpenApi or Swagger integration to Lumen

568 0
giahojnost/lumen-swagger

OpenApi or Swagger integration to Lumen, Retouched based on DarkaOnLine/SwaggerL...

28 0
darkaonline/swagger-lume

OpenApi or Swagger integration to Lumen

2,430,302 330
wotz/laravel-swagger-ui

Add Swagger UI to a Laravel application.

443,323 281
tartanlegrand/laravel-openapi

Generate OpenAPI Specification for Laravel Applications

220,252 38