abraham foto abraham foto - 23 days ago 6
PHP Question

Google page speed returning object rather than the speed

this is my controller.i am trying to integrate the google page speed to my laravel project.

class TestController extends Controller
{
public function pagespeed()
{
$pageSpeed = new \PageSpeed\Insights\Service();
$pagespeed = $pageSpeed->getResults('http://www.thesecretlab.nl');
return $pagespeed;
}
}


the output is a whole array.I wanted to get the speed value?

Answer

You could replace:

return $pagespeed;

By:

return $pagespeed['ruleGroups']['SPEED']['score'];