PHPackages                             dsentker/phpinsights - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. dsentker/phpinsights

ActiveLibrary[HTTP &amp; Networking](/categories/http)

dsentker/phpinsights
====================

A php wrapper for Googles page speed insights

0.2.2(8y ago)11519.1k↑68.9%22[3 issues](https://github.com/dsentker/phpinsights/issues)[2 PRs](https://github.com/dsentker/phpinsights/pulls)1PHPPHP ^5.4 || ^7.0

Since Jan 13Pushed 3y ago3 watchersCompare

[ Source](https://github.com/dsentker/phpinsights)[ Packagist](https://packagist.org/packages/dsentker/phpinsights)[ RSS](/packages/dsentker-phpinsights/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (3)Versions (4)Used By (1)

PhpInsights
===========

[](#phpinsights)

An easy-to-use API Wrapper for [Googles PageSpeed Insights](https://developers.google.com/speed/docs/insights/v2/reference/pagespeedapi/runpagespeed). The JSON response is mapped to objects for an headache-free usage.

Installation
------------

[](#installation)

1. Get an api key from the google developer console for [Page Speed Insights](https://console.developers.google.com/apis/api/pagespeedonline-json.googleapis.com/overview).
2. `composer require dsentker/phpinsights`
3. Have fun with this library.

Usage
-----

[](#usage)

### Simple 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

[](#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

[](#result-details)

#### Full result

[](#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

[](#result-details-by-rule-group)

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

### Screenshot

[](#screenshot)

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

Testing
-------

[](#testing)

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

Credits
-------

[](#credits)

- [Daniel Sentker](https://github.com/dsentker)
- [Nils](https://github.com/nlzet)
- [Joe Dawson](https://github.com/JoeDawson)
- [tlafon](https://github.com/tlafon)
- [baileyherbert](https://github.com/baileyherbert)

Submitting bugs and feature requests
------------------------------------

[](#submitting-bugs-and-feature-requests)

Bugs and feature request are tracked on GitHub.

ToDo
----

[](#todo)

- Write more tests
- Improve my english skills

External Libraries
------------------

[](#external-libraries)

This library depends on [JsonMapper by cweiske](https://github.com/cweiske/jsonmapper) to map json fields to php objects and [Guzzle](https://github.com/guzzle/guzzle) (surprise!).

Copyright and license
---------------------

[](#copyright-and-license)

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

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~163 days

Total

3

Last Release

3131d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9309c19594a948d4f0314bbdb2d3cfd56c84027fbd0fac6497c3e7098046be63?d=identicon)[dsentker](/maintainers/dsentker)

---

Top Contributors

[![dsentker](https://avatars.githubusercontent.com/u/86192?v=4)](https://github.com/dsentker "dsentker (27 commits)")[![joedawson](https://avatars.githubusercontent.com/u/1009696?v=4)](https://github.com/joedawson "joedawson (1 commits)")[![niels3W](https://avatars.githubusercontent.com/u/13118004?v=4)](https://github.com/niels3W "niels3W (1 commits)")[![thomaslafon](https://avatars.githubusercontent.com/u/25437521?v=4)](https://github.com/thomaslafon "thomaslafon (1 commits)")

---

Tags

google-insightsgoogle-pagespeed-insightspagespeedpagespeed-insightspagespeed-insights-api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dsentker-phpinsights/health.svg)

```
[![Health](https://phpackages.com/badges/dsentker-phpinsights/health.svg)](https://phpackages.com/packages/dsentker-phpinsights)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42361.9k4](/packages/bitpay-sdk)[seatsio/seatsio-php

A PHP client for the seats.io API

17793.2k](/packages/seatsio-seatsio-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
