Saturday, March 25, 2023
HomePHPA bundle to run Google Lighthouse utilizing PHP

A bundle to run Google Lighthouse utilizing PHP


Google Lighthouse is an open-source, automated device for boosting the top quality of website. It has audits for efficiency, availability, modern internet applications, SEARCH ENGINE OPTIMIZATION, and also extra.

Our most recent bundle, spatie/lighthouse-php makes it very easy to run Lighthouse utilizing PHP. In this post, I would love to inform you everything about it.

Presenting Google Lighthouse

Lighthouse is an open-source device developed by Google. It can investigate any kind of web site.

The record Lighthouse produces in-depth info and also recommendations for boosting the efficiency and also top quality of a site. It can be utilized to investigate a large range of variables, consisting of the rate at which a web page lots, the availability of the web page for customers with specials needs, and also the safety of the web page.

Among the essential advantages of utilizing Google Lighthouse is that it gives particular, workable recommendations for boosting the top quality of a site. For instance, if Lighthouse determines that a web page is sluggish to lots, it might recommend enhancing photos or minifying JavaScript to enhance efficiency. By executing these recommendations, a site can end up being quicker, extra available, and also extra safe, boosting its position in online search engine outcomes.

A Lighthouse record likewise includes fascinating metrics that permit web designers and also programmers to recognize the existing state of a site and also track progression gradually. These numbers can assist recognize locations of a site that require one of the most focus and also check the performance of any kind of adjustments made.

Below’s what such a record appears like.

The record includes numerous ideas on exactly how to enhance your website.

The Lighthouse expansion Chrome permits you to promptly produce a record for any kind of web site you are going to. However you can likewise run it from the command line and also as a node component

Running Lighthouse utilizing PHP

Our most recent bundle, spatie/lighthouse-php permits you to run Lighthouse utilizing PHP.

The bundle makes running Lighthouse a one-liner:

$ result  =  Lighthouse::  link(' https://example.com')->> run();

Realize that Lighthouse requires time to run. In my examinations, it balanced in between 30 and also 40 secs.

That result is a circumstances of SpatieLighthouseLighthouseResult, including numerous helpful features to get fascinating points from the outcome. In the copying, we will certainly obtain ball games for the 5 significant Lighthouse groups.

$ result->> ratings(); // returns a range similar to this one: 
/ *
 * [
 *    'performance' => 98,
 *    'accessibility' => 83,
 *    'best-practices' => 90,
 *    'seo' => 92,
 *    'pwa' => 43,  
 * ]
 */

Below’s exactly how to obtain the outcomes of a particular audit.

$ result->> audit(' first-contentful-paint') // returns this range

/ *
 * [
 *     'id' => 'first-contentful-paint'
 *     'title' => 'First Contentful Paint'
 *     'score' => 0.98
 *     'scoreDisplayMode' => 'numeric'
 *     'numericValue' => 1262.95
 *     'numericUnit' => 'millisecond'
 *     'displayValue' => '1.3 s'
 * ]
 */

Lighthouse can produce a well formatted HTML record with ball games and also outcomes of all audits.

 usage  SpatieLighthouseLighthouse;

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

This is exactly how that record searches in the web browser.

The spatie/lighthouse-php bundle has even more choices, so make certain to have a look at our comprehensive docs

Constant surveillance of Lighthouse outcomes

Oh Precious is a surveillance solution that not just keeps track of the uptime of your homepage, yet it creeps your whole web site and also sends out notices when it spots busted web links It likewise provides sophisticated checks, such as set up work checking and also application health and wellness surveillance

Among the brand-new checks I’m dealing with is the Lighthouse check. This check will consistently run Lighthouse versus your website, and also Oh Precious will certainly reveal one of the most vital metrics and also their advancement.

As well as you can also see the whole HTML record.

This info will certainly likewise be readily available with our API

We’ll likewise alert you when Lighthouse spots problems. In the setups, you can personalize when you wish to be alerted.

Currently, we are beta screening this brand-new check. It will certainly be readily available for each and every Oh Precious customer in the January – February 2023 duration.

If you’re not utilizing Oh Precious currently, you can register to begin your 10 day cost-free test

In closing

Google Lighthouse is a convenient device that can assist you enhance your web site. Our spatie/lighthouse-php makes it very easy to produce a Lighthouse record utilizing PHP. Read the comprehensive paperwork to find out all the choices and also opportunities.

This isn’t the very first bundle that we have actually released. On the Spatie web site, have a look at all our open-source bundles in this lengthy listing If you wish to sustain us, take into consideration getting any one of our paid items

RELATED ARTICLES

Most Popular

Recent Comments