PHP HAR is a lightweight package for working with HTTP Archive (HAR) files. Built with ❤️ by DeploymentHawk.
You can install the package via Composer:
composer require deploymenthawk/php-har
Create a new instance of Har
, by passing in your HAR JSON export:
$har = new \DeploymentHawk\Har($json);
Return the total number of network requests:
$har->totalRequests(); // 99
Return a Collection
of network requests:
$har->requests()->each(function(\DeploymentHawk\Request $request) {
$request->url(); // https://github.com/
$request->method(); // GET
$request->status(); // 200
$request->type(); // document
$request->priority(); // VeryHigh
$request->ipAddress(); // 140.82.121.4
$request->time(); // 266.54
$request->size(); // 45771
$request->uncompressedSize(); // 223478
$request->blockedTiming(); // 140.56
$request->dnsTiming(); // 0.01
$request->connectTiming(); // 52.07
$request->sslTiming(); // 28.38
$request->sendTiming(); // 0.25
$request->waitTiming(); // 26.75
$request->receiveTiming(); // 46.90
$request->requestHeaders() // [name => value, ...]
$request->responseHeaders() // [name => value, ...]
})
Return the fastest network request:
$har->fastestRequest(); // \DeploymentHawk\Request
Return the slowest network request:
$har->slowestRequest(); // \DeploymentHawk\Request
Return the largest network request:
$har->largestRequest(); // \DeploymentHawk\Request
Return the smallest network request:
$har->smallestRequest(); // \DeploymentHawk\Request
Return the total number of bytes transferred for all network requests:
$har->totalSize(); // 1600544
Return the total number of bytes for all resources:
$har->totalUncompressedSize(); // 4896355
Return the time in milliseconds when the DOMContentLoaded
event fired:
$har->onContentLoadTiming(); // 580.40
Return the time in milliseconds when the load
event fired:
$har->onLoadTiming(); // 775.93