Download the PHP package pouya1364/probabilistic-php without Composer

On this page you can find all versions of the php package pouya1364/probabilistic-php. 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 probabilistic-php

probabilistic-php

Pure-PHP probabilistic data structures: Bloom Filter, Counting Bloom Filter, Cuckoo Filter, Count-Min Sketch, and HyperLogLog. No runtime dependencies, no Redis — everything runs in plain PHP memory.

Why this exists

JavaScript has bloom-filters and Go has BoomFilters — single, well-maintained libraries covering this whole family. PHP has had no equivalent: the existing Packagist options are either a bare Bloom filter, abandoned since the PHP 5.x–7.1 era, or require a running Redis server to do anything at all. This package fills that gap with a modern, fully tested, pure in-memory implementation for PHP 8.2+.

These are probabilistic structures

Every structure here trades a little accuracy for a large amount of memory. That is the point, not a bug:

If you need exact answers, use a real Set or a database. If you need to track membership or counts over millions of items in kilobytes of memory, these are the right tool.

Installation

Requires PHP 8.2+ and the ext-hash extension (bundled with PHP core).

Usage

Bloom Filter — membership testing, no false negatives

mightContain() returning false is a guarantee the item was never added. true means it probably was, with at most the configured false-positive rate.

Counting Bloom Filter — Bloom Filter with removal

Each slot is a counter (capped at 255) instead of a single bit, which is what allows removal. Removing an item that was never added throws — it would corrupt the counts of other items sharing those slots.

Cuckoo Filter — space-efficient membership with removal

Often more space-efficient than a Bloom filter for the same false-positive rate, with deletion built in. A FilterFullException is thrown if the filter is overfilled well past its expectedItems — create a larger one.

Count-Min Sketch — approximate frequency counting

Counts are never underestimated. Wider/deeper sketches reduce overestimation at the cost of memory. Two sketches of identical dimensions can be combined with merge().

HyperLogLog — approximate distinct-count (cardinality)

Estimates the cardinality of a stream using a tiny, fixed amount of memory regardless of how many items pass through. Two estimators of equal precision can be combined with merge(), giving exactly what a single estimator over the union would have produced.

Choosing a structure

You want to… Use Removal? Error
Test membership in minimal memory BloomFilter No Configurable false positives
…and also remove items CountingBloomFilter Yes Configurable false positives
…with better space efficiency and removal CuckooFilter Yes Low, fixed false positives
Count how often each item appears CountMinSketch No Never under, may over
Count how many distinct items appear HyperLogLog No 0.3–3.6% at precision 14

Error handling

Every exception this library throws implements Probabilistic\Exception\ExceptionInterface, so you can catch all of them in one place:

Each one also extends the closest SPL exception — for example InvalidConfigurationException extends \InvalidArgumentException — so existing catch blocks for the standard types keep working.

Testing

Because these structures are probabilistic, the test suite mixes two styles: exact assertions for the hard guarantees (a Bloom filter never reports a false negative; a Count-Min Sketch never underestimates) and statistical-tolerance assertions for the rest (observed false-positive and error rates stay within generous, meaningful bounds across many items). If you contribute, follow the same pattern rather than asserting exact equality on inherently approximate outputs.

Contributing

composer.lock is intentionally not committed: this is a library, so consumers resolve their own compatible dependency versions. Run composer check before opening a pull request — analysis, lint, and tests must all pass.

Framework integrations

Ready-made wiring to use these structures as named, pre-configured services in your framework of choice:

Other projects

More of my packages are listed on my GitHub profile.

License

MIT — see LICENSE.


All versions of probabilistic-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-hash 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 pouya1364/probabilistic-php contains the following files

Loading the files please wait ...