PHPackages                             akira/laravel-spectra - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. akira/laravel-spectra

ActiveLibrary[API Development](/categories/api)

akira/laravel-spectra
=====================

Illuminate your API — interactive inspector for Laravel 12 with Inertia + React

v0.2.0(5mo ago)413[1 PRs](https://github.com/akira-io/laravel-spectra/pulls)MITPHPPHP ^8.4CI passing

Since Nov 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/akira-io/laravel-spectra)[ Packagist](https://packagist.org/packages/akira/laravel-spectra)[ Docs](https://github.com/akira-io/laravel-spectra)[ GitHub Sponsors](https://github.com/Akira)[ RSS](/packages/akira-laravel-spectra/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (2)Dependencies (16)Versions (4)Used By (0)

Spectra API Inspector
=====================

[](#spectra-api-inspector)

**Illuminate your API** — Interactive API inspector for Laravel 12 with Inertia + React.

[![Latest Version on Packagist](https://camo.githubusercontent.com/e55984d309ebea3d58bf9db80f28d069c5b1806ae5f6ecab9d8f4d0100a74fd0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616b6972612f6c61726176656c2d737065637472612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/akira/laravel-spectra)[![GitHub Tests Action Status](https://camo.githubusercontent.com/cc77eec1a8f7688592ed5fd259332dfbb3075faad12de7cbf5f4742c7cddfbc9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616b6972612d696f2f6c61726176656c2d737065637472612f7068702d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/akira-io/laravel-spectra/actions?query=workflow%3Aphp-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/0aaab6cf91c6291ee97ee2c084fb345d5a3f71d0814429429952731af90e2539/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616b6972612f6c61726176656c2d737065637472612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/akira/laravel-spectra)

Spectra is a powerful, developer-focused API inspector built exclusively for Laravel 12 applications. It provides an embedded, interactive console accessible at `/spectra` that helps you explore, test, and debug your API endpoints during development.

Features
--------

[](#features)

- 🔍 **Auto-discovery** of all application routes and parameters
- 📋 **JSON Schema generation** (2020-12) from FormRequest validation rules
- ⚡ **Internal request execution** through Laravel's HTTP kernel
- 🔐 **Multiple authentication modes**: current user, impersonate, Bearer token, Basic auth
- 🍪 **Cookie inspector** with Laravel encryption support
- 🎨 **Modern React UI** built with Inertia.js (no external packages needed)
- 💾 **Request collections** with export/import functionality
- 🌙 **Dark mode** support
- 🔒 **Production-safe** with comprehensive security controls

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- Laravel 12.x
- Inertia.js (automatically included)

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require --dev akira/laravel-spectra
```

Install and publish configuration:

```
php artisan spectra:install
```

This will publish the configuration file to `config/spectra.php`.

Configuration
-------------

[](#configuration)

The configuration file provides comprehensive control over Spectra's behavior:

```
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',
    ],
];
```

Usage
-----

[](#usage)

### Accessing Spectra

[](#accessing-spectra)

Once installed, visit `/spectra` in your browser when running in a local environment. You must be authenticated and have the `use-spectra` permission.

### Gate Configuration

[](#gate-configuration)

By default, Spectra defines a `use-spectra` gate that checks if the user has a `developer` role. You can customize this in your `AuthServiceProvider`:

```
use Illuminate\Support\Facades\Gate;

Gate::define('use-spectra', function ($user) {
    return $user->email === 'admin@example.com';
});
```

### Authentication Modes

[](#authentication-modes)

Spectra supports four authentication modes for executing requests:

1. **Current User**: Execute requests as the currently authenticated user
2. **Impersonate**: Execute requests as a different user (requires `use-spectra` gate approval)
3. **Bearer Token**: Provide a Bearer token for authentication
4. **Basic Auth**: Use username/password authentication

### Working with Schemas

[](#working-with-schemas)

Spectra automatically generates JSON Schema (2020-12) from your FormRequest validation rules. Supported validation rules include:

- Basic types: `string`, `integer`, `numeric`, `boolean`, `array`
- Formats: `email`, `url`, `date`, `uuid`
- Constraints: `min`, `max`, `between`, `in` (enum), `regex`
- Files: `file`, `image`, `mimes`
- Modifiers: `nullable`, `required`, `sometimes`

### Request Collections

[](#request-collections)

Save frequently used requests as collections:

1. Configure your request (endpoint, parameters, auth mode)
2. Click "Save" in the Collections panel
3. Give it a name
4. Load it anytime with one click

Export/import collections as JSON for sharing with your team.

Security
--------

[](#security)

Spectra is designed with security as a top priority:

- **Disabled by default** outside local environments
- **Rate limiting** on request execution
- **Sensitive header stripping** (Authorization, Cookie, etc.)
- **Field masking** for sensitive data in responses
- **Gate-based authorization** for all features
- **No external network requests** — all execution is internal

### Production Safety

[](#production-safety)

Spectra will automatically return a 404 error when:

- `enabled` config is `false`
- `only_local` is `true` and the environment is not local

**Never enable Spectra in production environments.**

Extensibility
-------------

[](#extensibility)

### Service Container Bindings

[](#service-container-bindings)

All Spectra services are bound to the container and can be extended or replaced:

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

### Custom Schema Builders

[](#custom-schema-builders)

Override the schema builder to add custom rule conversions:

```
app()->extend(SchemaBuilder::class, function ($builder, $app) {
    // Add custom logic
    return $builder;
});
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run static analysis:

```
composer analyse
```

Format code:

```
composer format
```

CI/CD
-----

[](#cicd)

Spectra includes GitHub Actions workflows for:

- PHP tests with Pest
- Static analysis with Larastan
- Code style with Pint
- JavaScript build and type checking
- Commitlint for conventional commits
- Automated releases with release-it

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Contributions are welcome! Please follow the conventional commits specification for all commits.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability, please email . All security vulnerabilities will be promptly addressed.

Credits
-------

[](#credits)

- [Kidiatoliny](https://github.com/kidiatoliny)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance82

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

162d ago

Major Versions

v0.2.0 → 1.x-dev2025-12-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/c42e59ca0b3864a382dc0c3e290f8cf7d75bbe3eab10a3af0f71d5785f89d0bc?d=identicon)[kidiatoliny](/maintainers/kidiatoliny)

---

Top Contributors

[![kidiatoliny](https://avatars.githubusercontent.com/u/48266788?v=4)](https://github.com/kidiatoliny "kidiatoliny (56 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelinertiareactdeveloper-toolsakiraapi-inspectorlaravel-spectra

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/akira-laravel-spectra/health.svg)

```
[![Health](https://phpackages.com/badges/akira-laravel-spectra/health.svg)](https://phpackages.com/packages/akira-laravel-spectra)
```

###  Alternatives

[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)[tapp/filament-webhook-client

Add a Filament resource and a policy for Spatie Webhook client

1120.2k](/packages/tapp-filament-webhook-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
