Skip to content
A PHP library for working with HTTP Archives
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
bin
src
tests
.gitignore
.php_cs.dist
README.md
composer.json
phpunit.xml.dist

README.md

HTTP Archive for PHP

CircleCI Packagist

Requirements

  • PHP 7.2+
  • The ext-json extension.

Installation

composer require deviantintegral/har, or download the CLI tool.

Introduction

This library supports reading and writing HTTP Archive files. These archives are JSON objects containing one or more HTTP request and response pairs. In particular, this library is useful for taking HTTP requests exported from a browser's developer tools or with a proxy like mitmproxy and using them as mocks in tests.

Features include:

  • Reading a HAR into a fully-typed set of classes.
  • Writing a \Deviantintegral\Har\Har back out into a HAR JSON string.
  • Adapters for PSR-7 Request and Response interfaces.
  • An interface and \Deviantintegral\Har\HarRepository class to load HARs from a filesystem or other backend.
  • A CLI tool to split a HAR file into single files per request / response pair.

Example

See ReadmeTest.php for an example of how to use this library.

Optional values

The HAR specification documents some fields as -1 if they do not have a value. Other fields, like comment, may be omitted.

Fields that may be omitted will have a has method that should be called before calling get. For integer fields, the return value must be checked for -1.

You can’t perform that action at this time.