PHP code example of kirschbaum-development / redactor

1. Go to this page and download the library: Download kirschbaum-development/redactor 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/ */

    

kirschbaum-development / redactor example snippets


'stack' => [
    'driver' => 'stack',
    'channels' => explode(',', env('LOG_STACK', 'single')),
    'tap' => [Kirschbaum\Redactor\Logging\RedactorTap::class],
],

use Kirschbaum\Redactor\Facades\Redactor;

Redactor::redact([
    'user_id' => 123,
    'password' => 'hunter2',
    'email' => '[email protected]',
    'note' => 'card 4111 1111 1111 1111 on file',
]);

// [
//     'user_id' => 123,
//     'password' => '[REDACTED]',
//     'email' => '[REDACTED]',
//     'note' => 'card ***************1111 on file',
//     '_redacted' => true,
// ]

$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

'operators' => [
    'default'     => 'redact',                                    // [REDACTED]
    'email'       => ['surrogate' => ['preserve_domain' => true]], // [email protected], stable
    'credit_card' => ['partial' => ['keep' => 4]],                 // ************1111
    'ssn'         => 'nullify',                                    // null, so a typed field stays typed
],