A lighthouse-style diagnostics tool that scans Laravel applications for performance, security, and architecture issues.
otatechie/laravel-spotlight is a Laravel package for a lighthouse-style diagnostics tool that scans laravel applications for performance, security, and architecture issues..
It currently has 9 GitHub stars and 113 downloads on Packagist (latest version v1.1.0).
Install it with composer require otatechie/laravel-spotlight.
Discover more Laravel packages by otatechie
or browse all Laravel packages to compare alternatives.
Last updated
A lighthouse-style diagnostics tool that scans Laravel applications for performance, security, and architecture issues. Built with a modular rule system that makes it easy to extend and customize.
Spotlight is NOT:
Spotlight IS:
Laravel Spotlight helps you identify and fix issues in your Laravel application before they become problems. It scans your application for:
Spotlight provides guidance, not enforcement. No shaming, no judgment.
Laravel Spotlight is a friendly mentor, not an angry linter. We help you improve your code with gentle suggestions, not shame or rigid rules.
See Why Spotlight? to see how it compares to other tools.
You can install the package via composer:
composer require otatechie/laravel-beacon
You can publish the config file with:
php artisan vendor:publish --tag="spotlight-config"
The config file lets you:
See the configuration documentation for details.
Run a full scan of your application:
php artisan spotlight:scan
Scan only performance issues:
php artisan spotlight:scan --category=performance
Scan multiple categories:
php artisan spotlight:scan --category=performance --category=security
php artisan spotlight:scan --format=json
Only show critical issues:
php artisan spotlight:scan --severity=critical
Spotlight uses exit codes for CI/CD integration:
Exit Code Mapping:
0 - No issues found (clean scan)1 - Only low severity issues found2 - Medium or high severity issues found3 - Critical issues foundUsage Examples:
# Default: Auto-detect exit code based on severity
php artisan spotlight:scan
# Fail only on critical issues
php artisan spotlight:scan --fail-on=critical
# Fail on high or critical issues
php artisan spotlight:scan --fail-on=high
# Fail on any issues (including low)
php artisan spotlight:scan --fail-on=low
GitHub Actions Example:
name: Run Spotlight Scan
run: php artisan spotlight:scan || exit 1
See all available rules:
php artisan spotlight:rules
Get details about a specific rule:
php artisan spotlight:rules --rule=performance.config-cache
Generate a new rule class:
php artisan spotlight:make-rule MyCustomRule --category=performance --type=objective
This creates a rule class with proper structure and auto-registers it.
use Otatechie\Spotlight\Spotlight;
$spotlight = app(Spotlight::class);
$results = $spotlight->scan(['performance', 'security']);
// Access results
$summary = $results['summary'];
$categories = $results['categories'];
Spotlight uses a two-dimensional classification system:
Objective Rules (type: 'objective') - Firm recommendations based on hard facts
Advisory Rules (type: 'advisory') - Gentle suggestions based on best practices
Spotlight uses 4 severity levels with numeric weights for scoring:
| Level | Weight | Purpose |
|-------|--------|---------|
| critical | 100 | Production-breaking / security risk |
| high | 70 | Serious performance or stability issue |
| medium | 40 | Performance issues or config problems |
| low | 10 | Minor improvement / suggestion |
Health Score: Spotlight calculates a health score (0-100%) based on severity weights, giving you a quick overview of your application's status.
Category-Based Defaults: If a rule doesn't specify severity, it inherits from its category:
highmediumlowAll rules can be disabled in config/spotlight.php if they don't apply to your project.
env() calls that should use config()$fillable or $guardedWant to add your own rules? It's easy. Check out the Creating Rules Guide for the full walkthrough.
Here's how simple it is:
<?php
namespace App\Spotlight\Rules\Performance; // Category auto-detected from namespace!
use Otatechie\Spotlight\Rules\AbstractRule;
class MyCustomRule extends AbstractRule
{
// Only define what's different - everything else is auto-detected!
protected ?string $severity = 'medium'; // Or leave null for category-based default
protected string $description = 'Checks for a specific issue';
protected ?string $documentationUrl = 'https://example.com/docs/my-rule';
// id: auto-generated as 'performance.my-custom'
// category: auto-detected as 'performance' from namespace
// name: auto-generated as 'My Custom' from class name
// severity: defaults to 'medium' (performance category default)
public function scan(): array
{
if ($issueFound) {
return $this->suggest(
'Issue description',
['recommendation' => 'How to fix it']
);
}
return $this->pass('Everything looks good!');
}
}
Register it in config/spotlight.php:
return [
'custom_rules' => [
\App\Spotlight\Rules\MyCustomRule::class,
],
];
Publish the config file:
php artisan vendor:publish --tag="spotlight-config"
Key configuration options:
enabled_rules - Enable/disable specific rulescustom_rules - Register your own custom rulesseverity_threshold - Filter rules by severity levelthresholds - Customize rule-specific thresholds (e.g., controller line limits)debug - Enable debug loggingerror_handling - Control error handling behaviorSee Examples & Configuration for more details.
Please see CHANGELOG for more information on what has changed recently.
Contributions are welcome! Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
Laravel is a trademark of Taylor Otwell. This package is not officially associated with Laravel or Taylor Otwell. The "laravel-" prefix in the package name is used to indicate compatibility with the Laravel framework and follows community naming conventions.