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.0.0(yesterday)31↑2900%MITPHPPHP ^8.2CI passing

Since Jun 18Pushed todayCompare

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

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

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

[](#privacy-filter)

[![Tests status](https://github.com/DirectoryTree/PrivacyFilter/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/DirectoryTree/PrivacyFilter/actions/workflows/run-tests.yml)

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();
```

Thresholds
----------

[](#thresholds)

The classifier uses a default threshold of `0.5`. The threshold is the minimum confidence score an entity must meet before it is returned. Increasing the threshold returns fewer, higher-confidence entities, while decreasing it may return more entities with lower confidence.

You may provide a threshold at runtime when classifying text:

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

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\PrivacyFilter\Facades\PrivacyFilter;
use DirectoryTree\PrivacyFilterClassifier\Entity;

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

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

1d 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 (31 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

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.5k](/packages/larastan-larastan)[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76518.2M115](/packages/laravel-mcp)[zidbih/laravel-deadlock

Make temporary Laravel workarounds expire and fail CI when ignored.

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

PHPackages © 2026

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