A PHP package to redact or fake array values by their keys.

v1.0 2019-07-14 20:43 UTC

This package is auto-updated.

Last update: 2022-11-15 05:03:37 UTC


A PHP package to redact or fake array values by their keys no matter how deep the array.

Latest Version on Packagist GitHub commits Total Downloads GitHub contributors GitHub issues


This packages uses the mtownsend/array-redactor package by mtownsend5512 and the Faker library by fzaninotto. So for more details to those packages look at the repositories readme files:


Sometimes you need to customized your data to protect the privacy of your users or the security of your application. This is no longer a problem with this package.

With this package, an element of an array or a JSON, no matter how deep, can be easily deleted, redact or faked. This allows you to customize the response of your server or api and pass it on without worry.


Install via composer:

composer require tobymaxham/array-faker-redactor

Quick start

Using the class

use TobyMaxham\ArrayFakerRedactor\ArrayFakerRedactor;

// An example array, maybe a request being made to/from an API application
$content = [
    'email'       => '',
    'phone'       => '1234567',
    'password'    => 'secret123',
    'notes'       => 'this can be removed',
    'sample_data' => 'nothing else matters',

$redactor = (new ArrayFakerRedactor())->content($content)->keys(['email', 'password', 'notes', 'sample_data' => 'random'])->withFaker()->redact();

// $redactor will return something like:
    'email'       => '',
    'phone'       => '1234567',
    'password'    => ']61i8~}DJB',
    'notes'       => '[REDACTED]',
    'sample_data' => 'e2k9aDUoeXRFQzhP',

Advanced usage

You can also add your own FakerProvider (see Faker Docs).

$content = [
    'key' => 'some data',

$redactor = (new ArrayFakerRedactor())->content($content)->keys(['key' => 'myformatter'])


You can run the tests with:



Please see CONTRIBUTING for details.


  • TobyMaxham


The MIT License (MIT). Please see License File for more information.