ghostwriter / redaction
Redaction library for PHP
0.1.x-dev
2026-06-15 15:28 UTC
Requires
- php: ~8.4.0 || ~8.5.0 || ~8.6.0
- ext-mbstring: *
Requires (Dev)
- ext-xdebug: *
- boundwize/structarmed: ^0.13.4
- ghostwriter/coding-standard: dev-main
- ghostwriter/container: ^7.0.2
- ghostwriter/phpunit-assertions: ^0.1.0
- ghostwriter/testify: ^0.1.2
- mockery/mockery: ^1.6.12
- phpunit/phpunit: ^13.2.0
- symfony/var-dumper: ^8.1.0
This package is auto-updated.
Last update: 2026-06-15 15:52:28 UTC
README
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.