PHP code example of elgigi / har-parser

1. Go to this page and download the library: Download elgigi/har-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

elgigi / har-parser example snippets


use ElGigi\HarParser\Parser;

$harFile = new Parser();

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

use ElGigi\HarParser\Entities\Log;

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

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;
}