1. Go to this page and download the library: Download mtownsend/array-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/ */
mtownsend / array-redactor example snippets
/*
* Package Service Providers...
*/
Mtownsend\ArrayRedactor\Providers\ArrayRedactorServiceProvider::class,
use Mtownsend\ArrayRedactor\ArrayRedactor;
// An example array, maybe a request being made to/from an API application you wish to log in your database
$login = [
'email' => '[email protected]',
'password' => 'secret123',
'data' => [
'session_id' => 'z481jf0an4kasnc8a84aj831'
],
];
$redactor = (new ArrayRedactor($login, ['password', 'session_id']))->redact();
// $redactor will return:
[
'email' => '[email protected]',
'password' => '[REDACTED]',
'data' => [
'session_id' => '[REDACTED]'
],
];
use ArrayRedactor;
// Laravel prefills our keys() and ink() methods for us from the config file
ArrayRedactor::content($array)->redact();
try {
$redactor = (new ArrayRedactor('i am an invalid argument', ['password']))->redact();
} catch (\Mtownsend\ArrayRedactor\Exceptions\ArrayRedactorException $exception) {
// do something...
}