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)615.8k—7.9%1MITPHPPHP ^8.0CI passing

Since Aug 27Pushed 7mo 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 yesterday

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 87% of packages

Maintenance45

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

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

833d 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

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)

PHPackages © 2026

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