{"id":13660291,"url":"https://github.com/dsentker/phpinsights","last_synced_at":"2025-09-10T03:43:30.721Z","repository":{"id":56972855,"uuid":"78629248","full_name":"dsentker/phpinsights","owner":"dsentker","description":"A versatile PHP Library for Google PageSpeed Insights","archived":false,"fork":false,"pushed_at":"2023-02-01T08:18:55.000Z","size":41,"stargazers_count":114,"open_issues_count":5,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-25T01:37:36.594Z","etag":null,"topics":["google-insights","google-pagespeed-insights","pagespeed","pagespeed-insights","pagespeed-insights-api"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dsentker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-11T10:42:41.000Z","updated_at":"2025-05-16T08:49:03.000Z","dependencies_parsed_at":"2023-02-17T03:20:29.014Z","dependency_job_id":null,"html_url":"https://github.com/dsentker/phpinsights","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/dsentker/phpinsights","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2Fphpinsights","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2Fphpinsights/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2Fphpinsights/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2Fphpinsights/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsentker","download_url":"https://codeload.github.com/dsentker/phpinsights/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsentker%2Fphpinsights/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274408370,"owners_count":25279466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-insights","google-pagespeed-insights","pagespeed","pagespeed-insights","pagespeed-insights-api"],"created_at":"2024-08-02T05:01:19.773Z","updated_at":"2025-09-10T03:43:30.678Z","avatar_url":"https://github.com/dsentker.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# PhpInsights\n\nAn 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. \n\n## Installation\n1. 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).\n2. ```composer require dsentker/phpinsights```\n3. Have fun with this library.\n\n## Usage\n\n### Simple Usage\n```php\n$url = 'http://example.com';\n\n$caller = new \\PhpInsights\\InsightsCaller('your-google-api-key-here', 'de');\n$response = $caller-\u003egetResponse($url, \\PhpInsights\\InsightsCaller::STRATEGY_MOBILE);\n$result = $response-\u003egetMappedResult();\n\nvar_dump($result-\u003egetSpeedScore()); // 100 \nvar_dump($result-\u003egetUsabilityScore()); // 100 \n```\n\n### Using Concurrent Requests\n```php\n$urls = array(\n    'http://example.com', \n    'http://example2.com', \n    'http://example3.com'\n);\n\n$caller = new \\PhpInsights\\InsightsCaller('your-google-api-key-here', 'fr');\n$responses = $caller-\u003egetResponses($urls, \\PhpInsights\\InsightsCaller::STRATEGY_MOBILE);\n\nforeach ($responses as $url =\u003e $response) {\n    $result = $response-\u003egetMappedResult();\n\n    var_dump($result-\u003egetSpeedScore()); // 100 \n    var_dump($result-\u003egetUsabilityScore()); // 100 \n}\n```\n\n### Result details\n#### Full result\n```php\n/** @var \\PhpInsights\\Result\\InsightsResult $result */\nforeach($result-\u003egetFormattedResults()-\u003egetRuleResults() as $rule =\u003e $ruleResult) {\n    \n    /*\n     * If the rule impact is zero, it means that the website has passed the test.\n     */\n    if($ruleResult-\u003egetRuleImpact() \u003e 0) {\n    \n        var_dump($rule); // AvoidLandingPageRedirects\n        var_dump($ruleResult-\u003egetLocalizedRuleName()); // \"Zielseiten-Weiterleitungen vermeiden\"\n        \n        /*\n         * The getDetails() method is a wrapper to get the `summary` field as well as `Urlblocks` data. You\n         * can use $ruleResult-\u003egetUrlBlocks() and $ruleResult-\u003egetSummary() instead. \n         */\n        foreach($ruleResult-\u003egetDetails() as $block) {\n            var_dump($block-\u003etoString()); // \"Auf Ihrer Seite sind keine Weiterleitungen vorhanden\"\n        }\n    \n    }\n    \n}\n```\n#### Result details by Rule group\n```php\n/** @var \\PhpInsights\\Result\\InsightsResult $result */\nforeach($result-\u003egetFormattedResults()-\u003egetRuleResultsByGroup(RuleGroup::GROUP_SPEED) as $rule =\u003e $ruleResult) {\n    $ruleResult-\u003egetSummary()-\u003etoString();\n}\n```\n\n### Screenshot\n```php\nprint $result-\u003escreenshot-\u003egetImageHtml(); // html image element\nprint $result-\u003escreenshot-\u003egetData(); // base64 screenshot representation \n```\n\n## Testing\n``` $ phpunit --bootstrap \"path/to/phpinsights/src/autoload.php\"```\n\n## Credits\n* [Daniel Sentker](https://github.com/dsentker)\n* [Nils](https://github.com/nlzet)\n* [Joe Dawson](https://github.com/JoeDawson)\n* [tlafon](https://github.com/tlafon)\n* [baileyherbert](https://github.com/baileyherbert)\n\n\n## Submitting bugs and feature requests\nBugs and feature request are tracked on GitHub.\n\n## ToDo\n* Write more tests\n* Improve my english skills\n\n## External Libraries\nThis 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!).\n\n## Copyright and license\nPhpInsights is licensed for use under the MIT License (MIT). Please see LICENSE for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsentker%2Fphpinsights","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsentker%2Fphpinsights","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsentker%2Fphpinsights/lists"}