PHPackages                             dzava/lighthouse - 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. dzava/lighthouse

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

dzava/lighthouse
================

Interface for the Google Lighthouse project

v0.2.0(4y ago)4010.4k↓100%18MITPHPPHP &gt;=7.4CI failing

Since Oct 23Pushed 4y ago2 watchersCompare

[ Source](https://github.com/dzava/lighthouse-php)[ Packagist](https://packagist.org/packages/dzava/lighthouse)[ Docs](https://github.com/dzava/lighthouse-php)[ RSS](/packages/dzava-lighthouse/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Lighthouse
==========

[](#lighthouse)

This package provide a php interface for [Google Lighthouse](https://github.com/GoogleChrome/lighthouse).

Installation
------------

[](#installation)

You can install the package via composer: `composer require dzava/lighthouse`

Install Lighthouse `yarn add lighthouse`. Last tested with Lighthouse v8.5.1.

Usage
-----

[](#usage)

Here's an example that will perform the default Lighthouse audits and store the result in `report.json` (You can use the [Lighthouse Viewer](https://googlechrome.github.io/lighthouse/viewer/) to open the report):

```
use Dzava\Lighthouse\Lighthouse;

(new Lighthouse())
    ->setOutput('report.json')
    ->accessibility()
    ->bestPractices()
    ->performance()
    ->pwa()
    ->seo()
    ->audit('http://example.com');
```

### Output

[](#output)

The `setOutput` method accepts a second argument that can be used to specify the format (json,html). If the format argument is missing then the file extension will be used to determine the output format. If the file extension does not specify an accepted format, then json will be used.

You can output both the json and html reports by passing an array as the second argument. For the example the following code will create two reports `example.report.html` and `example.report.json`.

```
use Dzava\Lighthouse\Lighthouse;

(new Lighthouse())
    ->setOutput('example', ['html', 'json'])
    ->performance()
    ->audit('http://example.com');
```

### Using a custom config

[](#using-a-custom-config)

You can provide your own configuration file using the `withConfig` method.

```
use Dzava\Lighthouse\Lighthouse;

(new Lighthouse())
    ->withConfig('./my-config.js')
    ->audit('http://example.com');
```

You can also pass a php array to the `withConfig` method containing your configuration.

```
use Dzava\Lighthouse\Lighthouse;

(new Lighthouse())
    ->withConfig([
         'extends' => 'lighthouse:default',
         'settings' => [
             'onlyCategories' => ['accessibility'],
         ],
     ])
    ->audit('http://example.com');
```

**Note:** in order to use an array to specify the configuration options, php needs to be able to [create and move](https://www.php.net/manual/en/function.tmpfile.php) temporary files.

Details about the configuration options can be found [here](https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md)

### Customizing node and Lighthouse paths

[](#customizing-node-and-lighthouse-paths)

If you need to manually set these paths, you can do this by calling the `setNodeBinary` and `setLighthousePath` methods.

```
use Dzava\Lighthouse\Lighthouse;

(new Lighthouse())
    ->setNodeBinary('/usr/bin/node')
    ->setLighthousePath('./node_modules/lighthouse/lighthouse-cli/index.js')
    ->audit('http://example.com');
```

### Passing flags to Chrome

[](#passing-flags-to-chrome)

Use the `setChromeFlags` method to pass any flags to the Chrome instance.

```
use Dzava\Lighthouse\Lighthouse;

(new Lighthouse())
    // these are the default flags used
    ->setChromeFlags(['--headless', '--disable-gpu', '--no-sandbox'])
    ->audit('http://example.com');
```

Troubleshooting
---------------

[](#troubleshooting)

#### Audit of 'url' failed

[](#audit-of-url-failed)

Use the following snippet to check why the audit fails.

```
require "./vendor/autoload.php";

use Dzava\Lighthouse\Exceptions\AuditFailedException;
use Dzava\Lighthouse\Lighthouse;

try {
(new Lighthouse())
    ->performance()
    ->audit('http://example.com');
} catch(AuditFailedException $e) {
    echo $e->getOutput();
}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~143 days

Total

2

Last Release

1515d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f5c257b625706f22f168252097c508646c5043227ea557da551221702702ccea?d=identicon)[dzava](/maintainers/dzava)

---

Top Contributors

[![dzava](https://avatars.githubusercontent.com/u/1516475?v=4)](https://github.com/dzava "dzava (26 commits)")

---

Tags

lighthouse

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/typescript-transformer

This is my package typescript-transformer

3706.5M16](/packages/spatie-typescript-transformer)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)[shivas/versioning-bundle

Symfony application versioning, simple console command to manage version (with providers e.g. git tag) of your application using Semantic Versioning 2.0.0 recommendations

1121.2M1](/packages/shivas-versioning-bundle)[eclipxe/cfdiutils

PHP Common utilities for Mexican CFDI 3.2, 3.3 &amp; 4.0

141129.9k6](/packages/eclipxe-cfdiutils)[shyim/danger-php

Port of danger to PHP

8544.9k](/packages/shyim-danger-php)[vaimo/composer-changelogs

Provide information about package changes based on changelog files that are bundled with releases; provide tools for generating documentation files from changelog sources

11150.5k10](/packages/vaimo-composer-changelogs)

PHPackages © 2026

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