ghostwriter/redaction

Redaction library for PHP

Maintainers

Package info

github.com/ghostwriter/redaction

pkg:composer/ghostwriter/redaction

Fund package maintenance!

ghostwriter

Paypal

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.x-dev 2026-06-15 15:28 UTC

This package is auto-updated.

Last update: 2026-06-15 15:52:28 UTC


README

Automation PHP Version Packagist Downloads PayPal Sponsors via GitHub

Redaction library for PHP

Warning

This project is not finished yet, work in progress.

Installation

You can install the package via composer:

composer require ghostwriter/redaction

Star ⭐️ this repo if you find it useful

You can also star (🌟) this repo to find it easier later.

Usage

use Ghostwriter\Redaction\Redactor;
use Ghostwriter\Redaction\Rules;
use Ghostwriter\Redaction\Rule;

###################################################
# Default redaction
###################################################
$redactor = Redactor::new();

$redactedText = $redactor->redact('GITHUB_TOKEN=abc123');
echo $redactedText; // Outputs: GITHUB_TOKEN=**REDACTED**

$redactedText = $redactor->redact('gho_abc123');
echo $redactedText; // Outputs: gho_**REDACTED**

$redactedText = $redactor->redact('ghs_abc123');
echo $redactedText; // Outputs: ghs_**REDACTED**

###################################################
# Custom redaction
###################################################
$customRules = [
    '#my_custom_pattern#iu' => '**my_custom_replacement**',
];

$redactor = Redactor::new($customRules);

$redactedText = $redactor->redact('my_custom_pattern');
echo $redactedText; // Outputs: **my_custom_replacement**

###################################################
# Custom redaction rules
###################################################
$customRules = [
    '#my_custom_pattern#iu' => '**my_custom_replacement**',
];

$rules = Rules::new($customRules);
$rules->add(Rule::new('#another_pattern#iu', '**another_replacement**'));

$redactor = new Redactor($rules);

$redactedText = $redactor->redact('my_custom_pattern');
echo $redactedText; // Outputs: **my_custom_replacement**

$redactedText = $redactor->redact('another_pattern');
echo $redactedText; // Outputs: **another_replacement**

Credits

Changelog

Please see CHANGELOG.md for more information on what has changed recently.

License

Please see LICENSE for more information on the license that applies to this project.

Security

Please see SECURITY.md for more information on security disclosure process.