This client library can be installed using composer:
composer require philcook/gtmetrix
use LightningStudio\GTMetrixClient\GTMetrixClient;
use LightningStudio\GTMetrixClient\GTMetrixTest;
$client = new GTMetrixClient();
$client->setUsername('[email protected]');
$client->setAPIKey('your-gtmetrix-api-key');
$client->getLocations();
$client->getBrowsers();
$test = $client->startTest('http://www.example.com/');
//Wait for result
while ($test->getState() != GTMetrixTest::STATE_COMPLETED &&
$test->getState() != GTMetrixTest::STATE_ERROR) {
$client->getTestStatus($test);
sleep(5);
}
From version 2.0 references to Entrecore have been replace with LightningStudio due to Entrecore no longer existing and therefore avoiding confusion for users.