A lightweight package for working with HAR files.

1.1.1 2024-04-24 12:20 UTC

This package is auto-updated.

Last update: 2024-11-24 13:47:05 UTC


README

GitHub Tests Action Packagist Version Packagist License

PHP HAR is a lightweight package for working with HTTP Archive (HAR) files. Built with ❤️ by DeploymentHawk.

Installation

You can install the package via Composer:

composer require deploymenthawk/php-har

Usage

Create a new instance of Har, by passing in your HAR JSON export:

$har = new \DeploymentHawk\Har($json);

Requests

totalRequests()

Return the total number of network requests:

$har->totalRequests(); // 99

requests()

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, ...]
})

fastestRequest()

Return the fastest network request:

$har->fastestRequest(); // \DeploymentHawk\Request

slowestRequest()

Return the slowest network request:

$har->slowestRequest(); // \DeploymentHawk\Request

largestRequest()

Return the largest network request:

$har->largestRequest(); // \DeploymentHawk\Request

smallestRequest()

Return the smallest network request:

$har->smallestRequest(); // \DeploymentHawk\Request

Page Weight

totalSize()

Return the total number of bytes transferred for all network requests:

$har->totalSize(); // 1600544

totalUncompressedSize()

Return the total number of bytes for all resources:

$har->totalUncompressedSize(); // 4896355

Timings

onContentLoadTiming()

Return the time in milliseconds when the DOMContentLoaded event fired:

$har->onContentLoadTiming(); // 580.40

onLoadTiming()

Return the time in milliseconds when the load event fired:

$har->onLoadTiming(); // 775.93