PHPackages                             pouya1364/probabilistic-bundle - 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. pouya1364/probabilistic-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

pouya1364/probabilistic-bundle
==============================

Symfony bundle integration for probabilistic-php — Bloom Filter, Counting Bloom Filter, Cuckoo Filter, Count-Min Sketch, and HyperLogLog as configured services.

v0.1.0(today)00MITPHPPHP ^8.2

Since Jun 20Pushed todayCompare

[ Source](https://github.com/pouya1364/probabilistic-bundle)[ Packagist](https://packagist.org/packages/pouya1364/probabilistic-bundle)[ RSS](/packages/pouya1364-probabilistic-bundle/feed)WikiDiscussions main Synced today

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

ProbabilisticBundle
===================

[](#probabilisticbundle)

Symfony integration for [`pouya1364/probabilistic-php`](https://packagist.org/packages/pouya1364/probabilistic-php). Define Bloom filters, Counting Bloom filters, Cuckoo filters, Count-Min sketches, and HyperLogLogs once in configuration, then access them anywhere in your application as named, pre-configured services.

For the algorithms themselves — accuracy guarantees, memory characteristics, and the maths behind each structure — see the core [`probabilistic-php`](https://github.com/pouya1364/probabilistic-php) library. This bundle is only the framework wiring.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Symfony 6.4, 7.x, or 8.x

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

[](#installation)

```
composer require pouya1364/probabilistic-bundle
```

If you use Symfony Flex the bundle is registered automatically. Otherwise enable it in `config/bundles.php`:

```
return [
    // ...
    ProbabilisticBundle\ProbabilisticBundle::class => ['all' => true],
];
```

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

[](#configuration)

Create `config/packages/probabilistic.yaml`. Every structure type holds any number of independently-sized, named instances — a real app typically needs several Bloom filters for different purposes, each configured differently.

```
probabilistic:
    bloom_filters:
        emails_seen:
            expected_items: 100000
            false_positive_rate: 0.01

    counting_bloom_filters:
        active_sessions:
            expected_items: 50000
            false_positive_rate: 0.01

    cuckoo_filters:
        rate_limited_ips:
            expected_items: 100000

    count_min_sketches:
        page_view_counts:
            width: 2000
            depth: 5

    hyperloglogs:
        unique_visitors:
            precision: 14
```

### Configuration reference

[](#configuration-reference)

GroupPer-instance keysRequiredNotes`bloom_filters``expected_items` (int ≥ 1), `false_positive_rate` (float)both`counting_bloom_filters``expected_items` (int ≥ 1), `false_positive_rate` (float)bothsupports deletion`cuckoo_filters``expected_items` (int ≥ 1)yes`count_min_sketches``width` (int ≥ 1), `depth` (int ≥ 1)bothfrequency estimation`hyperloglogs``precision` (int, 4–18)nodefaults to `14`### Why `expected_items` and not `expectedItems`?

[](#why-expected_items-and-not-expecteditems)

The configuration keys are written in `snake_case` to match Symfony's configuration conventions (the same style as `false_positive_rate`, `framework.http_method_override`, and so on). The underlying `probabilistic-php` factories, however, take `camelCase` named arguments — `BloomFilter::create(expectedItems: …, falsePositiveRate: …)`.

The bundle bridges the two: it accepts your `snake_case` YAML and translates each key to its `camelCase` equivalent internally, right before constructing the structure. You write idiomatic Symfony config; the library still receives exactly the argument names it expects. You never have to think about the conversion — this note exists only so the difference isn't surprising if you compare your YAML against the library's method signatures.

Usage
-----

[](#usage)

### Option 1 — the registry

[](#option-1--the-registry)

Inject `ProbabilisticBundle\Registry\ProbabilisticRegistry` (autowired) and ask it for instances by name. Each instance is built lazily on first access and reused for the rest of the request.

```
use ProbabilisticBundle\Registry\ProbabilisticRegistry;

final class SignupService
{
    public function __construct(
        private readonly ProbabilisticRegistry $probabilistic,
    ) {
    }

    public function isProbablyDuplicate(string $email): bool
    {
        $seen = $this->probabilistic->bloomFilter('emails_seen');

        if ($seen->mightContain($email)) {
            return true;
        }

        $seen->add($email);

        return false;
    }
}
```

Available registry methods, each taking the instance name (defaulting to `'default'`):

MethodReturns`bloomFilter(string $name)``Probabilistic\BloomFilter``countingBloomFilter(string $name)``Probabilistic\CountingBloomFilter``cuckooFilter(string $name)``Probabilistic\CuckooFilter``countMinSketch(string $name)``Probabilistic\CountMinSketch``hyperLogLog(string $name)``Probabilistic\HyperLogLog`Asking for a name that isn't configured throws `ProbabilisticBundle\Registry\UnknownInstanceException`.

### Option 2 — direct named-service autowiring

[](#option-2--direct-named-service-autowiring)

Every configured instance is also registered as its own service, named `probabilistic..`, so you can wire a single specific structure straight into a service without going through the registry:

```
use Probabilistic\HyperLogLog;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

final class VisitorStats
{
    public function __construct(
        #[Autowire(service: 'probabilistic.hyperloglog.unique_visitors')]
        private readonly HyperLogLog $uniqueVisitors,
    ) {
    }

    public function record(string $visitorId): void
    {
        $this->uniqueVisitors->add($visitorId);
    }

    public function estimatedUniqueVisitors(): int
    {
        return $this->uniqueVisitors->estimate();
    }
}
```

The service ids follow the singular form of each group:

Configured underService id`bloom_filters``probabilistic.bloom_filter.``counting_bloom_filters``probabilistic.counting_bloom_filter.``cuckoo_filters``probabilistic.cuckoo_filter.``count_min_sketches``probabilistic.count_min_sketch.``hyperloglogs``probabilistic.hyperloglog.`Both approaches return the same shared instance for a given name within a request, so mixing them is fine.

Console
-------

[](#console)

List everything that is configured, grouped by structure type:

```
php bin/console probabilistic:list
```

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

36

—

LowBetter than 80% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38941304?v=4)[Pouya Amani](/maintainers/pouya1364)[@pouya1364](https://github.com/pouya1364)

---

Top Contributors

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

---

Tags

symfonybundleBloom Filterprobabilistic-data-structures

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pouya1364-probabilistic-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/pouya1364-probabilistic-bundle/health.svg)](https://phpackages.com/packages/pouya1364-probabilistic-bundle)
```

PHPackages © 2026

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