All Projects → dsentker → phpinsights

dsentker / phpinsights

Licence: MIT license
A versatile PHP Library for Google PageSpeed Insights

Programming Languages

PHP
23972 projects - #3 most used programming language
Batchfile
5799 projects

Projects that are alternatives of or similar to phpinsights

pagespeedParseR
pagespeedParseR is an R wrapper for Google Pagespeed Insights API, that also enables convenient parsing
Stars: ✭ 20 (-81.65%)
Mutual labels:  pagespeed, pagespeed-insights, pagespeed-insights-api
Pagespeed exporter
Prometheus pagespeed exporter
Stars: ✭ 149 (+36.7%)
Mutual labels:  pagespeed
Web Monitoring
前端监控,性能监控平台。The front end monitoring platform focuses on Web end experience data monitoring. Three aspects of the health of Web pages are monitored: page opening speed (speed measurement), page stability (JS Error), and external service call success rate (API).
Stars: ✭ 592 (+443.12%)
Mutual labels:  pagespeed
Gp Vue Boilerplate
Grabarz & Partner Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites with vuejs.
Stars: ✭ 71 (-34.86%)
Mutual labels:  pagespeed
Vestacp nginx pagespeed http2
Rebuild Nginx with Google PageSpeed and http/2 for VestaCP
Stars: ✭ 16 (-85.32%)
Mutual labels:  pagespeed
Html Minifier
A simple command line tool to minify your HTML, Razor views & Web Forms views
Stars: ✭ 123 (+12.84%)
Mutual labels:  pagespeed
Incubator Pagespeed Ngx
Automatic PageSpeed optimization module for Nginx
Stars: ✭ 4,327 (+3869.72%)
Mutual labels:  pagespeed
awesome-performance-testing
A collection of awesome performance testing resources
Stars: ✭ 125 (+14.68%)
Mutual labels:  pagespeed
Magento Footer Js
Magento extension to move all JavaScript to the end of the page
Stars: ✭ 146 (+33.94%)
Mutual labels:  pagespeed
Docker Google Lighthouse
Google Lighthouse - Docker Image
Stars: ✭ 46 (-57.8%)
Mutual labels:  pagespeed
Magento2 Plugin
Speed up your Magento 2 webshop. Optimize your JPEG and PNG images automatically with TinyPNG.
Stars: ✭ 38 (-65.14%)
Mutual labels:  pagespeed
Pagespeed Score
DEPRECATED - use GoogleChrome/lighthouse-ci instead
Stars: ✭ 18 (-83.49%)
Mutual labels:  pagespeed
Nginx Ee
Automated Nginx compilation from sources with additional modules support. Compatible with WordOps, EasyEngine & Plesk
Stars: ✭ 132 (+21.1%)
Mutual labels:  pagespeed
Incubator Pagespeed Mod
Apache module for rewriting web pages to reduce latency and bandwidth.
Stars: ✭ 640 (+487.16%)
Mutual labels:  pagespeed
Hiper
🚀 A statistical analysis tool for performance testing
Stars: ✭ 2,667 (+2346.79%)
Mutual labels:  pagespeed
Webp server go
Go version of WebP Server. A tool that will serve your JPG/PNGs as WebP format with compression, on-the-fly.
Stars: ✭ 543 (+398.17%)
Mutual labels:  pagespeed
Kabarvirus
KabarVirus.com: cepat (PageSpeed 100), ringan (10 KB)
Stars: ✭ 109 (+0%)
Mutual labels:  pagespeed
Jquery.lazy
A lightweight, fast, feature-rich, powerful and highly configurable delayed content, image and background lazy loading plugin for jQuery & Zepto.
Stars: ✭ 965 (+785.32%)
Mutual labels:  pagespeed
nginx-more
Development repository for nginx-more package
Stars: ✭ 96 (-11.93%)
Mutual labels:  pagespeed
Incubator Pagespeed Cpanel
mod_pagespeed module for CPanel WHM
Stars: ✭ 143 (+31.19%)
Mutual labels:  pagespeed

PhpInsights

An easy-to-use API Wrapper for Googles PageSpeed Insights. The JSON response is mapped to objects for an headache-free usage.

Installation

  1. Get an api key from the google developer console for Page Speed Insights.
  2. composer require dsentker/phpinsights
  3. Have fun with this library.

Usage

Simple Usage

$url = 'http://example.com';

$caller = new \PhpInsights\InsightsCaller('your-google-api-key-here', 'de');
$response = $caller->getResponse($url, \PhpInsights\InsightsCaller::STRATEGY_MOBILE);
$result = $response->getMappedResult();

var_dump($result->getSpeedScore()); // 100 
var_dump($result->getUsabilityScore()); // 100 

Using Concurrent Requests

$urls = array(
    'http://example.com', 
    'http://example2.com', 
    'http://example3.com'
);

$caller = new \PhpInsights\InsightsCaller('your-google-api-key-here', 'fr');
$responses = $caller->getResponses($urls, \PhpInsights\InsightsCaller::STRATEGY_MOBILE);

foreach ($responses as $url => $response) {
    $result = $response->getMappedResult();

    var_dump($result->getSpeedScore()); // 100 
    var_dump($result->getUsabilityScore()); // 100 
}

Result details

Full result

/** @var \PhpInsights\Result\InsightsResult $result */
foreach($result->getFormattedResults()->getRuleResults() as $rule => $ruleResult) {
    
    /*
     * If the rule impact is zero, it means that the website has passed the test.
     */
    if($ruleResult->getRuleImpact() > 0) {
    
        var_dump($rule); // AvoidLandingPageRedirects
        var_dump($ruleResult->getLocalizedRuleName()); // "Zielseiten-Weiterleitungen vermeiden"
        
        /*
         * The getDetails() method is a wrapper to get the `summary` field as well as `Urlblocks` data. You
         * can use $ruleResult->getUrlBlocks() and $ruleResult->getSummary() instead. 
         */
        foreach($ruleResult->getDetails() as $block) {
            var_dump($block->toString()); // "Auf Ihrer Seite sind keine Weiterleitungen vorhanden"
        }
    
    }
    
}

Result details by Rule group

/** @var \PhpInsights\Result\InsightsResult $result */
foreach($result->getFormattedResults()->getRuleResultsByGroup(RuleGroup::GROUP_SPEED) as $rule => $ruleResult) {
    $ruleResult->getSummary()->toString();
}

Screenshot

print $result->screenshot->getImageHtml(); // html image element
print $result->screenshot->getData(); // base64 screenshot representation 

Testing

$ phpunit --bootstrap "path/to/phpinsights/src/autoload.php"

Credits

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub.

ToDo

  • Write more tests
  • Improve my english skills

External Libraries

This library depends on JsonMapper by cweiske to map json fields to php objects and Guzzle (surprise!).

Copyright and license

PhpInsights is licensed for use under the MIT License (MIT). Please see LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].