PHPackages                             spatie/lighthouse-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. spatie/lighthouse-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

spatie/lighthouse-php
=====================

Run Google Lighthouse using PHP

2.0.1(7mo ago)26861.5k↓48.1%312MITPHPPHP ^8.3CI passing

Since Nov 4Pushed 1w ago7 watchersCompare

[ Source](https://github.com/spatie/lighthouse-php)[ Packagist](https://packagist.org/packages/spatie/lighthouse-php)[ Docs](https://github.com/spatie/lighthouse-php)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-lighthouse-php/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (6)Versions (25)Used By (2)

 [   ![Logo for lighthouse-php](https://camo.githubusercontent.com/0187df8b56aed74a3e4f8c4e671dac0ece4e21c1ebe467ea31bb2aa629a35dc4/68747470733a2f2f7370617469652e62652f7061636b616765732f6865616465722f6c69676874686f7573652d7068702f68746d6c2f6c696768742e77656270)  ](https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=lighthouse-php)Run Google Lighthouse using PHP
===============================

[](#run-google-lighthouse-using-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0f382346fc8de513bdfb78a614efd333183df232a858798f3cae6dc8e7e9384a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c69676874686f7573652d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/lighthouse-php)[![Tests](https://github.com/spatie/lighthouse-php/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/spatie/lighthouse-php/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/2c97ff2fa08cd9cd45b5d9b4c9d6bf5f0169889c695cf6fe1f85e29cd92c1a09/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c69676874686f7573652d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/lighthouse-php)

[Google Lighthouse](https://developer.chrome.com/docs/lighthouse/overview/) 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;

// 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:

```
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()
    ->maxWaitForLoad(5000) // Wait max 5 seconds for page load
    ->run();
```

Here's how you can get the results of an audit:

```
$result->audit('first-contentful-paint') // returns this array

/*
 * [
 *     'id' => 'first-contentful-paint'
 *     'title' => 'First Contentful Paint'
 *     'score' => 0.98
 *     'scoreDisplayMode' => 'numeric'
 *     'numericValue' => 1262.95
 *     'numericUnit' => 'millisecond'
 *     'displayValue' => '1.3 s'
 * ]
 */
```

You can also write a full HTML report to disk:

```
$result->saveHtml($pathToReport)
```

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/490f99650426aa848042dc06f1c200db639564bf478356addf00f03440dcf8e1/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c69676874686f7573652d7068702e6a70673f743d31)](https://spatie.be/github-ad-click/lighthouse-php)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Documentation
-------------

[](#documentation)

All documentation is available [on our documentation site](https://spatie.be/docs/lighthouse-php).

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

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

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

This package contains code copied from [Laravel's `Arr` class](https://github.com/laravel/framework/blob/9.x/src/Illuminate/Collections/Arr.php).

License
-------

[](#license)

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

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance83

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 71% 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 ~48 days

Recently: every ~142 days

Total

24

Last Release

220d ago

Major Versions

0.0.10 → 1.0.02022-12-14

1.3.1 → 2.0.02025-10-20

PHP version history (2 changes)0.0.1PHP ^8.1

2.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (176 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (25 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (16 commits)")[![StyleShit](https://avatars.githubusercontent.com/u/32631382?v=4)](https://github.com/StyleShit "StyleShit (10 commits)")[![mattiasgeniar](https://avatars.githubusercontent.com/u/407270?v=4)](https://github.com/mattiasgeniar "mattiasgeniar (5 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (3 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (3 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![Jamesking56](https://avatars.githubusercontent.com/u/253237?v=4)](https://github.com/Jamesking56 "Jamesking56 (2 commits)")[![justinbuhrmann1997](https://avatars.githubusercontent.com/u/26270692?v=4)](https://github.com/justinbuhrmann1997 "justinbuhrmann1997 (1 commits)")[![JamesCobbledick](https://avatars.githubusercontent.com/u/56843244?v=4)](https://github.com/JamesCobbledick "JamesCobbledick (1 commits)")[![Pluuk](https://avatars.githubusercontent.com/u/11299826?v=4)](https://github.com/Pluuk "Pluuk (1 commits)")[![rubenvanerk](https://avatars.githubusercontent.com/u/20305359?v=4)](https://github.com/rubenvanerk "rubenvanerk (1 commits)")[![danielstgt](https://avatars.githubusercontent.com/u/13825655?v=4)](https://github.com/danielstgt "danielstgt (1 commits)")[![Jonnx](https://avatars.githubusercontent.com/u/1399475?v=4)](https://github.com/Jonnx "Jonnx (1 commits)")

---

Tags

best-practicesgooglelighthouseperformancephpseospatielighthouse-php

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatie-lighthouse-php/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-lighthouse-php/health.svg)](https://phpackages.com/packages/spatie-lighthouse-php)
```

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[spatie/typescript-transformer

This is my package typescript-transformer

3957.8M27](/packages/spatie-typescript-transformer)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[spatie/dns

Retrieve DNS records

6092.7M22](/packages/spatie-dns)[spatie/shiki-php

Highlight code using Shiki in PHP

31018.6M17](/packages/spatie-shiki-php)

PHPackages © 2026

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