spatie/lighthouse-php
Run Google Lighthouse audits from PHP. Test any URL and retrieve category scores (performance, accessibility, SEO, etc.) and individual audit details. Configure headers, user agent, categories, CPU throttling, and max load wait, then run and parse results.
Lighthouse::url() can be wrapped in a job for async execution). Complements existing Laravel tools like Laravel Horizon for queue monitoring.spatie/lighthouse-php + spatie/laravel-package-tools). Minimal boilerplate for basic usage.exec() or shell_exec() is used to launch Chrome (security implications; see Technical Risk).LighthouseResult) or stored in databases like MySQL/PostgreSQL.exec() to launch Chrome. Mitigation: Validate URLs, sanitize inputs, and restrict Chrome binary paths (e.g., via environment variables)..env) is critical.Lighthouse facade and binds the Lighthouse class to the container.LighthouseJob extending ShouldQueue).Lighthouse::url() in a custom command for CLI access (e.g., php artisan lighthouse:audit https://example.com).LighthouseResult can be stubbed).composer require spatie/lighthouse-php.$result = Lighthouse::url('https://example.com')->run();
dd($result->performanceScore);
use Spatie\Lighthouse\Jobs\RunLighthouse;
RunLighthouse::dispatch('https://example.com')->onQueue('lighthouse');
$result->toArray(); // Parse into a Laravel model
FROM chrome:stable).CHROME_BINARY env var).lighthouse_results)..env (e.g., LIGHTHOUSE_CHROME_BINARY=/usr/bin/chromium).CHROME_BINARY env var or system PATH.LIGHTHOUSE_TIMEOUT (default: 30s) or optimize audit scope.Lighthouse::url()->debug() to log Chrome commands.spatie-lighthouse).How can I help you explore Laravel packages today?