Saving an HTML report | lighthouse-php | Spatie

 SPATIE

  Lighthouse PHP
=================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Lighthouse-php](https://spatie.be/docs/lighthouse-php/v2)  Usage  Saving an HTML report

 Version   v2

 Other versions for crawler [v2](https://spatie.be/docs/lighthouse-php/v2)

- [ Introduction ](https://spatie.be/docs/lighthouse-php/v2/introduction)
- [ Support us ](https://spatie.be/docs/lighthouse-php/v2/support-us)
- [ Requirements ](https://spatie.be/docs/lighthouse-php/v2/requirements)
- [ Installation &amp; setup ](https://spatie.be/docs/lighthouse-php/v2/installation-setup)
- [ Questions and issues ](https://spatie.be/docs/lighthouse-php/v2/questions-issues)
- [ Changelog ](https://spatie.be/docs/lighthouse-php/v2/changelog)
- [ About us ](https://spatie.be/docs/lighthouse-php/v2/about-us)

Usage
-----

- [ Generating your first report ](https://spatie.be/docs/lighthouse-php/v2/usage/generating-your-first-report)
- [ Configuring a run ](https://spatie.be/docs/lighthouse-php/v2/usage/configuring-a-run)
- [ Working with results ](https://spatie.be/docs/lighthouse-php/v2/usage/working-with-results)
- [ Saving an HTML report ](https://spatie.be/docs/lighthouse-php/v2/usage/saving-an-html-report)
- [ Using performance budgets ](https://spatie.be/docs/lighthouse-php/v2/usage/using-performance-budgets)

 Saving an HTML report
=====================

Lighthouse can generate a nicely formatted HTML report with the scores and results of all audits.

```
use Spatie\Lighthouse\Lighthouse;

Lighthouse::url('https://example.com')
    ->run()
    ->saveHtml($pathToFile);
```

This is how that report looks like in the browser.

![screenshot](https://spatie.be/docs/lighthouse-php/v2/images/report.jpg)

To get the HTML, without save it to a file, simply call `html()`.

```
use Spatie\Lighthouse\Lighthouse;

$html = Lighthouse::url('https://example.com')
    ->run()
    ->html();
```
