PHP code example of lucajackal85 / pii-sanitizer-php
1. Go to this page and download the library: Download lucajackal85/pii-sanitizer-php 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/ */
lucajackal85 / pii-sanitizer-php example snippets
use Jackal\PiiSanitizer\Client\PiiSocketClient;
use Jackal\PiiSanitizer\Processor\PiiSanitizerProcessor;
$processor = new PiiSanitizerProcessor(
new PiiSocketClient('/tmp/sockets/pii_sanitizer.sock', connectTimeout: 0.05, readTimeout: 1.0),
onFailure: PiiSanitizerProcessor::ON_FAILURE_REDACT,
circuitBreakerSeconds: 5.0,
);
$handler->pushProcessor($processor); // per handler, or $logger->pushProcessor($processor)
use Jackal\PiiSanitizer\Client\MaskingStrategy;
use Jackal\PiiSanitizer\Client\PiiSocketClient;
$client = new PiiSocketClient('/tmp/sockets/pii_sanitizer.sock');
$client->sanitize('John Doe called support'); // "[PRIVATE_PERSON] called support"
$client->sanitize('John Doe called support', MaskingStrategy::Hash); // "[PRIVATE_PERSON_4c2a] called support"
$client->sanitize('John Doe called support', MaskingStrategy::Asterisk); // "******** called support"
bash
composer
bash
composer install
composer check # php-cs-fixer + rector (dry run), PHPStan and PHPUnit, like CI
composer cs-fix # apply php-cs-fixer
composer rector-fix # apply rector
PII_SOCKET_PATH=/tmp/sockets/pii_sanitizer.sock php examples/demo.php # against a running engine
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.