GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - octoper/lighthouse-php: A PHP interface for Google Lighthouse

BranchesTags
Open more actions menu

Latest commit

 

History

38 Commits
38 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
tests
tests
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.php_cs
.php_cs
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
package.json
package.json
 
 
phpstan.neon.dist
phpstan.neon.dist
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 

Repository files navigation

Lighthouse

Tests StyleCI Packagist Version Packagist Downloads License

This package is a fork of dzava/lighthouse-php

This package provides a PHP interface for Google Lighthouse.

Installation

You can install the package via composer:

composer require octoper/lighthouse-php

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 to open the report):

use Octoper\Lighthouse\Lighthouse;

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

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 Octoper\Lighthouse\Lighthouse;

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

Using a custom config

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

use Octoper\Lighthouse\Lighthouse;

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

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 Octoper\Lighthouse\Lighthouse;

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

Passing flags to Chrome

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

use Octoper\Lighthouse\Lighthouse;

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

Testing

composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

  • dzava
  • octoper
  • All Contributors

License

The MIT License (MIT). Please see License File for more information.

About

A PHP interface for Google Lighthouse

Topics

google-lighthouselighthouselighthouse-php

Resources

Readme
MIT license
Activity

Stars

4 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.