1. Go to this page and download the library: Download dzava/lighthouse library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dzava / lighthouse example snippets
use Dzava\Lighthouse\Lighthouse;
(new Lighthouse())
->setOutput('report.json')
->accessibility()
->bestPractices()
->performance()
->pwa()
->seo()
->audit('http://example.com');
use Dzava\Lighthouse\Lighthouse;
(new Lighthouse())
->setOutput('example', ['html', 'json'])
->performance()
->audit('http://example.com');
use Dzava\Lighthouse\Lighthouse;
(new Lighthouse())
->withConfig('./my-config.js')
->audit('http://example.com');
use Dzava\Lighthouse\Lighthouse;
(new Lighthouse())
->withConfig([
'extends' => 'lighthouse:default',
'settings' => [
'onlyCategories' => ['accessibility'],
],
])
->audit('http://example.com');
use Dzava\Lighthouse\Lighthouse;
(new Lighthouse())
->setNodeBinary('/usr/bin/node')
->setLighthousePath('./node_modules/lighthouse/lighthouse-cli/index.js')
->audit('http://example.com');
use Dzava\Lighthouse\Lighthouse;
(new Lighthouse())
// these are the default flags used
->setChromeFlags(['--headless', '--disable-gpu', '--no-sandbox'])
->audit('http://example.com');
use Dzava\Lighthouse\Exceptions\AuditFailedException;
use Dzava\Lighthouse\Lighthouse;
try {
(new Lighthouse())
->performance()
->audit('http://example.com');
} catch(AuditFailedException $e) {
echo $e->getOutput();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.