PHPackages                             directorytree/privacy-filter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. directorytree/privacy-filter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

directorytree/privacy-filter
============================

Laravel wrapper for privacy-filter.cpp binaries.

v1.1.0(1mo ago)5797↑100%MITPHPPHP ^8.2CI passing

Since Jun 18Pushed 1mo agoCompare

[ Source](https://github.com/DirectoryTree/PrivacyFilter)[ Packagist](https://packagist.org/packages/directorytree/privacy-filter)[ RSS](/packages/directorytree-privacy-filter/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (16)Versions (3)Used By (0)

Privacy Filter
==============

[](#privacy-filter)

[![Tests status](https://camo.githubusercontent.com/697ffe6574798fc54df0dfcfaa7bc8e86facca61562962b16cbd88ef287e9a6f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4469726563746f7279547265652f5072697661637946696c7465722f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/DirectoryTree/PrivacyFilter/actions)[![Total downloads](https://camo.githubusercontent.com/b1bf1a41dac2439b23f847464188b00fc7c6e4c6fde4b3faa31a9bbdfc6c45e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6469726563746f7279747265652f707269766163792d66696c7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/directorytree/privacy-filter)[![Latest version](https://camo.githubusercontent.com/f0c936dc2e20da53bcabd26843127e37434080254bbca4cf76687516cb59af99/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469726563746f7279747265652f707269766163792d66696c7465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/directorytree/privacy-filter)[![License](https://camo.githubusercontent.com/5bb2f940933018dfddeaf6a415923404c4c9f9831afa7c3dd6e107ea309a106f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4469726563746f7279547265652f5072697661637946696c7465723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/directorytree/privacy-filter)

Install and use compiled [`privacy-filter.cpp`](https://github.com/DirectoryTree/PrivacyFilterBinaries) binaries from Laravel applications.

Introduction
------------

[](#introduction)

Privacy Filter provides a Laravel wrapper around the `privacy-filter.cpp` command line binary. It installs [the compiled binary](https://github.com/DirectoryTree/PrivacyFilterBinaries) for the current operating system, downloads the GGUF model used by the binary, and exposes a small PHP API for detecting private entities in text.

Installation
------------

[](#installation)

You may install the package via Composer:

```
composer require directorytree/privacy-filter
```

After installing the package, run the `privacy-filter:install` Artisan command. This command will install both the compiled binary and the GGUF model required by the runtime API:

```
php artisan privacy-filter:install
```

If either file already exists, the installer will leave it in place. You may use the `--force` option to overwrite the installed files:

```
php artisan privacy-filter:install --force
```

Configuration
-------------

[](#configuration)

You may publish the package configuration file using the `vendor:publish` Artisan command:

```
php artisan vendor:publish --tag=privacy-filter-config
```

The published configuration file allows you to customize the installed binary path, model path, process timeout, model URL, and binary release source:

```
'paths' => [
    'binary' => env('PRIVACY_FILTER_BINARY_PATH', storage_path('app/privacy-filter/bin/privacy-filter')),
    'model' => env('PRIVACY_FILTER_MODEL_PATH', storage_path('app/privacy-filter/models/privacy-filter-f16.gguf')),
],

'process' => [
    'timeout' => (float) env('PRIVACY_FILTER_TIMEOUT', 60),
],

'model' => [
    'url' => env('PRIVACY_FILTER_MODEL_URL', 'https://huggingface.co/LocalAI-io/privacy-filter-GGUF/resolve/main/privacy-filter-f16.gguf'),
],

'release' => [
    'repository' => env('PRIVACY_FILTER_BINARY_REPOSITORY', 'DirectoryTree/PrivacyFilterBinaries'),
    'version' => env('PRIVACY_FILTER_BINARY_VERSION', 'v1.0.0'),
],
```

Installing Assets
-----------------

[](#installing-assets)

The `privacy-filter:install` command installs all assets required by the package:

```
php artisan privacy-filter:install
```

You may install the binary and model independently if you need more control over deployment:

```
php artisan privacy-filter:install-binary
php artisan privacy-filter:install-model
```

The binary installer downloads the correct archive for the current operating system from the configured GitHub release. You may install a different release or provide a direct archive URL:

```
php artisan privacy-filter:install-binary --release=v1.0.0
php artisan privacy-filter:install-binary --url=https://example.com/privacy-filter-darwin-arm64.tar.gz
```

The model installer downloads the configured GGUF model. You may also provide a direct model URL:

```
php artisan privacy-filter:install-model --url=https://example.com/privacy-filter.gguf
```

Usage
-----

[](#usage)

You may classify text using the `PrivacyFilter` facade. The `entities` method returns an array of `Entity` instances:

```
use DirectoryTree\PrivacyFilter\Facades\PrivacyFilter;

$entities = PrivacyFilter::entities('Contact John Doe at jdoe@example.com.');

/** @var \DirectoryTree\PrivacyFilterClassifier\Entity $entity */
foreach ($entities as $entity) {
    $entity->type;  // private_email
    $entity->text;  // jdoe@example.com
    $entity->start; // 20
    $entity->end;   // 36
    $entity->score; // 0.98
}
```

Each entity contains the detected type, original text, byte offsets, and confidence score. You may also retrieve the byte length of the entity:

```
$length = $entity->length();
```

You may use the detected entities to redact personal information from text:

```
use DirectoryTree\PrivacyFilter\Facades\PrivacyFilter;

$text = 'Contact John Doe at jdoe@example.com or 555-0100.';

// Find personal information.
$entities = PrivacyFilter::entities($text);

// Redact detected entities.
$redacted = collect($entities)->reduce(function (string $text, $entity) {
    return str_replace($entity->text, '[redacted]', $text);
}, $text);

// Contact [redacted] at [redacted] or [redacted].
echo $redacted;
```

Thresholds
----------

[](#thresholds)

The classifier uses a default threshold of `0.5`. Only entities with a confidence score equal to or greater than the threshold will be returned.

You may provide a threshold at runtime when classifying text:

```
$entities = PrivacyFilter::entities(
    text: 'Contact John Doe at jdoe@example.com.',
    threshold: 0.75,
);
```

Queueing And Memory
-------------------

[](#queueing-and-memory)

Privacy Filter runs the native `privacy-filter.cpp` binary when classifying text. The GGUF model is loaded into memory by the native process while classification is running. Larger models require more memory.

For production workloads, you should avoid running many classifications concurrently from normal web requests. Instead, dispatch classification work to a dedicated queue and limit the number of workers assigned to that queue based on the memory available on your server.

For example, if your selected model uses approximately 3 GB of memory while classifying, running four concurrent workers may require approximately 12 GB of memory, plus memory used by PHP, Redis, your database, and the rest of your application.

A typical Horizon configuration may dedicate a small worker pool to privacy filtering:

```
'privacy-filter' => [
    'connection' => 'redis',
    'queue' => ['privacy-filter'],
    'balance' => 'simple',
    'processes' => 2,
    'tries' => 1,
    'timeout' => 300,
],
```

You may then dispatch redaction or classification work to the dedicated queue:

```
RedactTranscript::dispatch($transcript)->onQueue('privacy-filter');
```

Tune the `processes` value according to your server memory and model size. Each concurrent classification may load its own copy of the model into memory.

Entity Types
------------

[](#entity-types)

The raw entity type is available through the entity's `type` property:

```
$entity->type;
```

For known privacy-filter entity types, you may retrieve the matching `EntityType` enum instance:

```
use DirectoryTree\PrivacyFilterClassifier\EntityType;

if ($entity->type() === EntityType::PrivateEmail) {
    // ...
}
```

If the binary returns an entity type that is not known by this package, the `type` method will return `null`.

Testing
-------

[](#testing)

You may use the `fake` method to prevent the package from invoking the installed binary during tests. The fake method accepts a list of entities that should be returned for every classification:

```
use DirectoryTree\PrivacyFilterClassifier\Entity;
use DirectoryTree\PrivacyFilter\Facades\PrivacyFilter;

PrivacyFilter::fake([
    new Entity(
        type: 'private_email',
        start: 20,
        end: 36,
        score: 0.98,
        text: 'jdoe@example.com',
    ),
]);
```

You may also fake responses for specific text using exact strings or wildcard patterns:

```
PrivacyFilter::fake([
    '*jdoe@example.com*' => [
        new Entity(
            type: 'private_email',
            start: 20,
            end: 36,
            score: 0.98,
            text: 'jdoe@example.com',
        ),
    ],
]);
```

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance92

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

43d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c6dd082636ff8a08df8dfdcd622ea242374d1d76dd33bceec5a6cd3ae26dc24f?d=identicon)[stevebauman](/maintainers/stevebauman)

---

Top Contributors

[![stevebauman](https://avatars.githubusercontent.com/u/6421846?v=4)](https://github.com/stevebauman "stevebauman (36 commits)")

---

Tags

classificationphppii-detection

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/directorytree-privacy-filter/health.svg)

```
[![Health](https://phpackages.com/badges/directorytree-privacy-filter/health.svg)](https://phpackages.com/packages/directorytree-privacy-filter)
```

###  Alternatives

[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

78727.1M205](/packages/laravel-mcp)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.4M352](/packages/psalm-plugin-laravel)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[spatie/laravel-export

Create a static site bundle from a Laravel app

679153.2k6](/packages/spatie-laravel-export)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k96.5k1](/packages/mike-bronner-laravel-model-caching)[zidbih/laravel-deadlock

Make temporary Laravel workarounds expire and fail CI when ignored.

1007.4k](/packages/zidbih-laravel-deadlock)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
