Lighthouse-php
Run Google Lighthouse using PHP
Google Lighthouse is an open-source, automated tool for improving the quality of web pages. It has audits for performance, accessibility, progressive web apps, SEO and more.
This package makes it easy to run Lighthouse using PHP. Here's an example on how to get the scores of the five categories of audits that Lighthouse offers.
use Spatie\Lighthouse\Lighthouse;
$result = Lighthouse::url('https://example.com')->run();
$result->scores();
It's easy to configure various options:
use Spatie\Lighthouse\Lighthouse;
use Spatie\Lighthouse\Enums\Category;
Lighthouse::url('https://example.com')
->userAgent('My user agent')
->headers(['MyExtraHeader' => 'HeaderValue'])
->categories(Category::Performance, Category::Accessibility)
->throttleCpu()
->run();
Here's how you can get the results of an audit:
$result->audit('first-contentful-paint')
You can also write a full HTML report to disk:
$result->saveHtml($pathToReport);