scalar/laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

scalar/laravel

最新稳定版本:0.2.0

Composer 安装命令:

composer require scalar/laravel

包简介

Render your OpenAPI-based API reference

README 文档

README

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 Horizon installation:

<?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.

统计信息

  • 总下载量: 43.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 51
  • 点击次数: 2
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 51
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固