PHP code example of akira / laravel-spectra

1. Go to this page and download the library: Download akira/laravel-spectra 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/ */

    

akira / laravel-spectra example snippets


return [
    // Enable/disable Spectra (defaults to local environment only)
    'enabled' => env('SPECTRA_ENABLED', app()->environment('local')),
    
    // Restrict to local environment only
    'only_local' => env('SPECTRA_ONLY_LOCAL', true),
    
    // Authentication guard to use
    'guard' => env('SPECTRA_GUARD', 'web'),
    
    // Gate for impersonation feature
    'impersonation_gate' => 'use-spectra',
    
    // Rate limiting for execute endpoint
    'rate_limit' => [
        'max' => 60,
        'per_minutes' => 1,
    ],
    
    // Headers to strip from requests
    'strip_headers' => [
        'authorization',
        'cookie',
        'x-api-key',
    ],
    
    // Fields to mask in responses
    'mask_fields' => [
        'password',
        'token',
        'authorization',
        'api_key',
        'secret',
    ],
];

use Illuminate\Support\Facades\Gate;

Gate::define('use-spectra', function ($user) {
    return $user->email === '[email protected]';
});

app()->bind(RouteScanner::class, function ($app) {
    return new CustomRouteScanner($app['router']);
});

app()->extend(SchemaBuilder::class, function ($builder, $app) {
    // Add custom logic
    return $builder;
});
bash
php artisan spectra:install
bash
composer analyse