adityadees/laravel-lighthouse

Package wrapper for laravel framework which can make it easier for you to run Google Lighthouse to audit websites.

v1.0.0 2023-04-22 09:03 UTC

This package is auto-updated.

Last update: 2024-12-17 19:17:41 UTC


README

A Google Lighthouse wrapper for laravel framework which can make it easier for you to run Google Lighthouse to audit websites. The audit results that have been completed will be saved automatically in your server directory.

run composer require adityadees/laravel-lighthouse then php artisan vendor:publish --tag=laravel-lighthouse

Before use this package you need define variable on config/laravel-lighthouse.php as global config

To use it you can run

# $url = optional, you can using global config or override it to this variable
# $device = optional, if blank will scan both, mobile and desktop mode
$lighouse = (new LaravelLighthouse())->run($url,$device);

// using default config option
$lighouse = (new LaravelLighthouse())->run();

// run both mobile and desktop
$lighouse = (new LaravelLighthouse())->run('https://adityadees.com');

// run only mobile
$lighouse = (new LaravelLighthouse())->run('https://adityadees.com', 'mobile');

// run only desktop
$lighouse = (new LaravelLighthouse())->run('https://adityadees.com', 'desktop');

// run only mobile with global url defined on config
$lighouse = (new LaravelLighthouse())->run('', 'mobile');

// run only desktop with global url defined on config
$lighouse = (new LaravelLighthouse())->run('', 'desktop');

or you can use your own custom configuration like this

# $url = optional, you can using global config or override it to this variable
# $flag = optional, you can use the config or define it on here
# $device = optional, if blank will scan both, mobile and desktop mode
$lighouse = (new LaravelLighthouse())->selfConfiguration($url,$flag,$device);


// using self configuration with config as default
$lighouse = (new LaravelLighthouse())->selfConfiguration('https://adityadees.com');

// run self configuration with override url, flag and both device
$lighouse = (new LaravelLighthouse())->selfConfiguration('https://adityadees.com', '--chrome-flags="--headless --no-sandbox --disable-gpu" --output html --output json --output-path ' . base_path() . '/public/laravel-lighthouse/mobile/result.html');

// run self configuration with override url, flag and device to mobile mode
$lighouse = (new LaravelLighthouse())->selfConfiguration('https://adityadees.com', '--chrome-flags="--headless --no-sandbox --disable-gpu" --output html --output json --output-path ' . base_path() . '/public/laravel-lighthouse/mobile/result.html', 'mobile');

// run self configuration with override url, flag and device to dekstop mode
$lighouse = (new LaravelLighthouse())->selfConfiguration('https://adityadees.com', '--chrome-flags="--headless --no-sandbox --disable-gpu" --preset=desktop --output html --output json --output-path ' . base_path() . '/public/laravel-lighthouse/desktop/result.html', 'desktop');

for more information about the flag you can visit https://github.com/GoogleChrome/lighthouse

if you following the configuration example the results should be like this

  • Inside folder public you can see the results .html and .json

https://github.com/adityadees/laravel-lighthouse/tree/docs/example-results/laravel-lighthouse

image

if you open the .html you can see the results like this

Desktop

image

Mobile image