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.
useSpatie\Lighthouse\Lighthouse;// returns an instance of Spatie\Lighthouse\LighthouseResult$result =Lighthouse::url('https://example.com')->run();$result->scores(); // returns an array like this one:/* * [ * 'performance' => 98, * 'accessibility' => 83, * 'best-practices' => 90, * 'seo' => 92, * 'pwa' => 43, * ] */
It's easy to configure various options:
useSpatie\Lighthouse\Lighthouse;useSpatie\Lighthouse\Enums\Category;Lighthouse::url('https://example.com')->userAgent('My user agent')->headers(['MyExtraHeader'=>'HeaderValue'])->categories(Category::Performance, Category::Accessibility)->throttleCpu()->run();