PHPackages                             denismitr/laravel-bloom - 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. denismitr/laravel-bloom

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

denismitr/laravel-bloom
=======================

Bloom filter implementation for Laravel based on Redis

v0.3(6y ago)91461[2 issues](https://github.com/denismitr/laravel-bloom/issues)MITPHPPHP ^7.1

Since Jun 12Pushed 6y agoCompare

[ Source](https://github.com/denismitr/laravel-bloom)[ Packagist](https://packagist.org/packages/denismitr/laravel-bloom)[ Docs](https://github.com/denismitr/laravel-bloom)[ RSS](/packages/denismitr-laravel-bloom/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (7)Versions (6)Used By (0)

Laravel Bloom filter implementation
-----------------------------------

[](#laravel-bloom-filter-implementation)

[![Build Status](https://camo.githubusercontent.com/33c7cd3fa6dbe5d2fb15fc0f7cd661dbac30ff033905e3f34b2f72512263a940/68747470733a2f2f7472617669732d63692e6f72672f64656e69736d6974722f6c61726176656c2d626c6f6f6d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/denismitr/laravel-bloom.svg?branch=master)

A Bloom filter is a space-efficient probabilistic data structure, conceived by Burton Howard Bloom in 1970, that is used to test whether an element is a member of a set. False positive matches are possible, but false negatives are not – in other words, a query returns either "possibly in set" or "definitely not in set". Elements can be added to the set, but not removed (though this can be addressed with a "counting" filter); the more elements that are added to the set, the larger the probability of false positives.

Read the [Full article on Wikipedia](https://en.wikipedia.org/wiki/Bloom_filter).

### Installation

[](#installation)

`composer require denismitr/laravel-bloom`

Latest version - **0.3**

### Configuration

[](#configuration)

```
php artisan vendor:publish --provider="Denismitr\Bloom\BloomServiceProvider" --tag="config"
```

Bloom filter configuration file: `bloom.php`

```
return [
    'default' => [
        'size' => 100000000,
        'num_hashes' => 5,
        'persistence' => [
            'driver' => 'redis',
            'connection' => 'default'
        ],
        'hashing_algorithm' => 'md5',
    ],

    'keys' => [
         // keys specific params
         // example
//        'user_recommendations' => [
//            'size' => 5500000,
//            'num_hashes' => 10,
//            'persistence' => [
//                'driver' => 'redis',
//                'connection' => 'default'
//            ],
//            'hashing_algorithm' => 'md5',
//        ]
    ],
];
```

`MAX_CAPACITY` for this Bloom filter implementation is currently at `4294967296`.

`default` section applies to all keys, unless they have a dedicated configuration, specified inside the `keys` section.

- `size` - is the size of the Bloom filter storage 10M-100M bit is recommended size
- `num_hashes` - is a number of hash functions applied to each item put into Bloom filter
- `persistance` - is an array containing persistence configuration - `driver` and `connection`
    - `driver` - at the moment only **redis** is supported
    - `connection` - for redis connection is specified in `redis` section of the `database.php` configuration file in standard Laravel setup.
- `hashing_algorithm` - self explanatory, at the moment `md5` and `murmur` hashing algorithms are supported.

### Usage

[](#usage)

you can use facade - `Denismitr\Bloom\Facades\Bloom` or just inject `Denismitr\Bloom\BloomManager` as dependency and it will be resolved by Laravel

### Default configuration with DI

[](#default-configuration-with-di)

```
public function someAction(Denismitr\Bloom\BloomManager $bloomManager)
{
    $bloomFilter = $bloomManager->key('foo');

    $bloomFilter->add('baz');
    ...
    $bloomFilter->test('baz'); // true
    ...
    $bloomFilter->clear(); // clear bloom filter under 'foo' key
}
```

##### Default configuration with facade

[](#default-configuration-with-facade)

```
Bloom::key("shown-banners")->add($banner->id);
...
Bloom::key("shown-banners")->test($banner->id);
// true
Bloom::key("shown-banners")->test($unseenBanner->id);
// false, but can be true sometimes (a false positive)

// reset bloom filter for given key
Bloom::key('shown-banners')->reset();
```

#### Key specific configuration

[](#key-specific-configuration)

in `bloom.php` find `keys` section and add a configuration for a **key** that you want to use with parameters others than `default`.

```
'keys' => [
    'seen-banners' => [
        'size' => 5550000,
        'num_hashes' => 3,
        'persistence' => [
            'driver' => 'redis',
            'connection' => 'default'
        ],
        'hashing_algorithm' => 'md5',
    ]
]
```

now when you use Bloom filter with that key it will use that configuration. `Bloom::key('seen-banners')->add($bammer->id)`

#### Key suffix

[](#key-suffix)

For your convenience there is an easy way to generate user specific keys, just pass user ID as a second argument when calling the `key` method like so:

```
Bloom::key('user-recommendation', $user->id)->add($recommendation->id);
```

or

```
$bloomFilter = Bloom::key('user-recommendation', $user->id);

$bloomFilter->add($recommendation->id);

$bloomFilter->test($recommendation->id); // true

// to clear that key do
$bloomFilter->clear();
```

### Testing

[](#testing)

- Test coverage &gt; 90%

`composer test`

For now you need an actual Redis set up on your machine.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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 ~1 days

Total

5

Last Release

2524d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d68ae5d5ca94f49a69f961a7825865d92247b09e276a25fcc6ad485d4c8c964?d=identicon)[denismitr](/maintainers/denismitr)

---

Top Contributors

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

---

Tags

laraveldata structuresBloom Filterbloomprobabilisticdenismitr

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/denismitr-laravel-bloom/health.svg)

```
[![Health](https://phpackages.com/badges/denismitr-laravel-bloom/health.svg)](https://phpackages.com/packages/denismitr-laravel-bloom)
```

###  Alternatives

[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[tonysm/importmap-laravel

Use ESM with importmap to manage modern JavaScript in Laravel without transpiling or bundling.

148399.8k1](/packages/tonysm-importmap-laravel)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)[watson/nameable

Format names of users into full, familiar and abbreviated forms

299.7k](/packages/watson-nameable)

PHPackages © 2026

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