Download the PHP package magebitcom/pii-redactor without Composer

On this page you can find all versions of the php package magebitcom/pii-redactor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pii-redactor

PII Redactor

Framework-agnostic PHP library for detecting and redacting PII in text. No runtime dependencies. PHP 8.1+.

Install

Quick start

Detect without redacting

Built-in detectors

EMAIL, PHONE, CREDIT_CARD (Luhn-validated), IBAN (mod-97-validated), IP_ADDRESS (v4/v6), MAC_ADDRESS, URL, CRYPTO_ADDRESS (BTC/ETH), DATE_OF_BIRTH.

Each detector lives in its own class under Detector\Builtin\ (regexes, validator and sanitize config), wired together by BuiltinDetectors.

Checksum validation is tri-state: a passing checksum forces confidence to 1.0, a failing one discards the match, otherwise the pattern's base score applies.

Context boosting

Weak patterns (a bare 8-digit phone number, an ambiguous date) carry a low base score on purpose. They only cross the reporting threshold (default 0.5) when a context word appears within ~40 characters before the match — +0.35 to the score, shown in the match's explanation (e.g. context "phone" (+0.35)). This is the library's primary false-positive control: without it, weak patterns either flood with noise at a high base score or stay undetectable.

The library ships a single English (en) context-word pack. To recognise terms in other languages, or words specific to your domain, extend the default pack with your own words — no fork required. ContextWords is immutable; withWords() merges onto an entity type's existing list (de-duplicated) and returns a copy:

Pass ContextWords::none() for a pack with no context words at all. For full control over a single detector's words, Builtin\PhoneDetector::create($words) still accepts a plain string[].

Opting out of boosting. To score matches purely on their patterns, inject the no-op enhancer (or build detectors without context words):

With boosting disabled, weak detectors (bare phone/date forms) stay below the default threshold and are not reported; strong detectors (email, validated card or IBAN) are unaffected.

Per-entity strategies

Options

Custom detectors

The optional fourth Pattern argument is a list of requiredNeedles: cheap literal substrings the engine checks with str_contains before running the regex. If none are present the regex is skipped entirely. Every needle must be guaranteed to appear in any real match (here, EMP- is part of the pattern), or matches will be lost. The built-in EMAIL/URL/CRYPTO/PHONE detectors use this to skip their regexes on the (common) lines that contain no @, ://, 0x, etc.

For ML-grade name/location detection, extend Detector\RemoteDetector and call your NER provider (Google DLP, AWS Comprehend, a Presidio sidecar); it handles chunking and fail-open/fail-closed behavior.

Performance & logging

Logging is often on a blocking hot path, so per-call latency matters. Construct PiiRedactor once and reuse it — do not build a new instance per log record. Construction wires up 9 detectors and their context-word packs, which costs about as much as a full short-line redaction; reusing the instance roughly halves per-call latency.

Measured on PHP 8.4 (Xdebug off), reusing a single instance:

Scenario µs/op
Clean short log line (no PII) ~5.3
Short line with one email ~5.9
new PiiRedactor() per call + redact ~11.0

So a naive (new PiiRedactor())->redact($line) inside a Monolog processor is ~2x slower than holding one instance on the processor. For a Monolog processor, build the redactor in the constructor and call redact() in __invoke().

A throwaway benchmark harness lives at tools/benchmark.php (php -dxdebug.mode=off tools/benchmark.php).

Guarantees & limits


All versions of pii-redactor with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package magebitcom/pii-redactor contains the following files

Loading the files please wait ...