PHP code example of philcook / gtmetrix
1. Go to this page and download the library: Download philcook/gtmetrix library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
philcook / gtmetrix example snippets
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);
}