1. Go to this page and download the library: Download scalar/laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Scalar\Facades\Scalar;
Scalar::document('API v1')->url('/openapi/v1.yaml');
Scalar::document('API v2')->file(storage_path('app/openapi/v2.json'))->default();
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, [
//
]);
});
}
}
bash
php artisan scalar:install
bash
# Publish the config file to config/scalar.php
php artisan vendor:publish --tag="scalar-config"
# Publish the Blade views (only needed if you want to customize them)
php artisan vendor:publish --tag="scalar-views"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.