Quick Start
Install the package and publish its configuration:
composer require kirschbaum-development/redactor
php artisan vendor:publish --tag=redactor-config
Add the tap to a log channel in config/logging.php. It pushes a Monolog processor, so the channel keeps its own formatter:
'stack' => [
'driver' => 'stack',
'channels' => explode(',', env('LOG_STACK', 'single')),
'tap' => [Kirschbaum\Redactor\Logging\RedactorTap::class],
],
Redact anything else directly:
use Kirschbaum\Redactor\Facades\Redactor;
Redactor::redact([
'user_id' => 123,
'password' => 'hunter2',
'email' => 'bob@example.com',
'note' => 'card 4111 1111 1111 1111 on file',
]);
// [
// 'user_id' => 123,
// 'password' => '[REDACTED]',
// 'email' => '[REDACTED]',
// 'note' => 'card ***************1111 on file',
// '_redacted' => true,
// ]
Ask what was found rather than reading it back out of the payload:
$result = Redactor::profile('strict')->withoutMarkers()->inspect($data);
$result->value; // the redacted payload
$result->wasRedacted; // true
$result->redactedKeys; // ['password', 'email']
$result->findings; // rule, entity, key, offset, length and confidence for each match