PHPackages                             elgigi/har-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. elgigi/har-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

elgigi/har-parser
=================

Library to parse HAR files

v1.1.0(2y ago)612.6k↓23.7%1MITPHPPHP ^8.0CI passing

Since Aug 27Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/ElGigi/HarParser)[ Packagist](https://packagist.org/packages/elgigi/har-parser)[ RSS](/packages/elgigi-har-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (9)Used By (1)

HAR Parser
==========

[](#har-parser)

[![Latest Version](https://camo.githubusercontent.com/111d3fedd7dfec83bb71719301efbd5779c48c4bec83efa92263b5b2c445bab3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c676967692f6861722d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://github.com/ElGigi/HarParser/releases)[![Software license](https://camo.githubusercontent.com/850dadf735bc83da8787d271fa4af596aa852b6110ab82a4a3a3bf963eac0c3a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f456c476967692f4861725061727365722e7376673f7374796c653d666c61742d737175617265)](https://github.com/ElGigi/HarParser/blob/main/LICENSE)[![Build Status](https://camo.githubusercontent.com/e3e7d4992ba05f7126963f618eda02e1bfacaf487ec7f99da5935160affb2fc0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f456c476967692f4861725061727365722f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/ElGigi/HarParser/actions/workflows/tests.yml?query=branch%3Amain)[![Quality Grade](https://camo.githubusercontent.com/5f4066c4e78ed0f1c7f9a6a2e20f91bf93311c7aba801105e67b73ec89981189/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f30343437613432393064653734346463383161376532636639383931613437642f6d61696e2e7376673f7374796c653d666c61742d737175617265)](https://app.codacy.com/gh/ElGigi/HarParser)[![Total Downloads](https://camo.githubusercontent.com/2e73866edb5ab7babb562220439e06e9e0df8b50c71e6d69e51b73b3ecd9955c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c676967692f6861722d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elgigi/har-parser)

Library to parse and generate [HAR file format](https://en.wikipedia.org/wiki/HAR_(file_format)).

Usage
-----

[](#usage)

Load you HAR file with an `Parser` object or with `Log` entity.

With `Parser` class:

```
use ElGigi\HarParser\Parser;

$harFile = new Parser();

$log = $harFile->parse('/path/of/my/file.har', contentIsFile: true);
$log = $harFile->parse(['my' => 'har decoded']);
```

With `Log` entity class:

```
use ElGigi\HarParser\Entities\Log;

$log = Log::load(json_decode(file_get_contents('/path/of/my/file.har'), true));
```

Entities
--------

[](#entities)

The HAR file is distributed in several entities:

- Log
    - Creator
    - Browser
    - Page\[\]
        - PageTimings
    - Entry\[\]
        - Request
            - Cookie\[\]
            - Header\[\]
            - PostData
        - Response
            - Cookie\[\]
            - Header\[\]
            - Content
        - Timings

Builder
-------

[](#builder)

Two builders are available to construct an HAR file from entities:

- `Builder`: build a `Log` entity from others entities
- `BuilderStream`: build directly the JSON file in stream to prevent memory usage

Both implements `BuilderInterface`:

- `BuilderInterface::reset(): void`: reset builder data
- `BuilderInterface::setVersion(string $version): void`: define version of HAR file (default: 1.2)
- `BuilderInterface::setCreator(string $creator): void`: set creator entity
- `BuilderInterface::setBrowser(string $browser): void`: set browser entity
- `BuilderInterface::addPage(Page ...$page): void`: add a page entity (or multiple pages)
- `BuilderInterface::addEntry(Entry ...$entry): void`: add an entry entity (or multiple entries)
- `BuilderInterface::setComment(?string $comment): void`: define comment of HAR file

For stream builder, the constructor attempt a valid resource (writeable and seekable).

For standard builder, the constructor accept an HAR file, for example, complete an existent HAR.

Anonymize HAR
-------------

[](#anonymize-har)

In some cases, like unit tests, you need to anonymize your HAR file.

The `Anonymizer` class it's do for that!

```
class Anonymizer
{
    /**
     * Add header to redact.
     *
     * @param string ...$regex
     *
     * @return void
     */
    public function addHeaderToRedact(string ...$regex): void;

    /**
     * Add query string to redact.
     *
     * @param string ...$regex
     *
     * @return void
     */
    public function addQueryStringToRedact(string ...$regex): void;

    /**
     * Add post data to redact.
     *
     * @param string ...$regex
     *
     * @return void
     */
    public function addPostDataToRedact(string ...$regex): void;

    /**
     * Add accepted mime.
     *
     * @param string ...$mime
     *
     * @return void
     */
    public function addAcceptedMime(string ...$mime): void;

    /**
     * Add content to redact.
     *
     * @param array $regexes
     *
     * @return void
     */
    public function addContentToRedact(array $regexes): void;

    /**
     * Add callback.
     *
     * @param callable ...$callback
     *
     * @return void
     */
    public function addCallback(callable ...$callback): void;

    /**
     * Anonymize HAR file.
     *
     * @param Log $log
     *
     * @return Log
     * @throws InvalidArgumentException
     */
    public function anonymize(Log $log): Log;
}
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance48

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~133 days

Recently: every ~143 days

Total

8

Last Release

787d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18268216?v=4)[Ronan Giron](/maintainers/ElGigi)[@ElGigi](https://github.com/ElGigi)

---

Top Contributors

[![ElGigi](https://avatars.githubusercontent.com/u/18268216?v=4)](https://github.com/ElGigi "ElGigi (41 commits)")

---

Tags

harhttphttp-logslogphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elgigi-har-parser/health.svg)

```
[![Health](https://phpackages.com/badges/elgigi-har-parser/health.svg)](https://phpackages.com/packages/elgigi-har-parser)
```

###  Alternatives

[amphp/http

Basic HTTP primitives which can be shared by servers and clients.

1038.5M34](/packages/amphp-http)[pcrov/jsonreader

JSON Pull Parser

1451.2M5](/packages/pcrov-jsonreader)[maxakawizard/json-collection-parser

Streaming parser for large JSON files containing array of objects

132833.5k8](/packages/maxakawizard-json-collection-parser)[magium/configuration-manager

Provides a generic plugable configuration management interface similar to Magento

2075.2k11](/packages/magium-configuration-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
