PHPackages                             travaux-com/variantretriever - 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. travaux-com/variantretriever

ActiveLibrary

travaux-com/variantretriever
============================

1.0.3(5y ago)2321.0k↓36.4%3MITPHPPHP &gt;=7.4

Since Sep 15Pushed 4y ago2 watchersCompare

[ Source](https://github.com/travaux-com/VariantRetriever)[ Packagist](https://packagist.org/packages/travaux-com/variantretriever)[ Docs](https://github.com/travaux-com/variantretriever)[ RSS](/packages/travaux-com-variantretriever/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

 VariantRetriever
==================

[](#--------variantretriever----)

VariantRetriever is a minimalist package for feature flagging. It's fast, database free and idempotent library to choose over a set of variants.

Getting Started
---------------

[](#getting-started)

First of all, you need to define an Experiment with a name and it variants. Variant requires 2 arguments, a name and a rollout percentage (50% by default). Then create a variant retriever with this experiment and variants, and ask it to retrieve a variant for a resource (in the following code, it's for a user uuid).

```
$variantRetriever = new VariantRetriever();
$experiment = new Experiment('my-ab-test', ...[new Variant('control1'), new Variant('variant2')]);
$variantRetriever->addExperiment($experiment);

$affectedVariant = $variantRetriever->getVariantForExperiment(new Experiment('my-ab-test'), '77d8a1d5-97ba-42db-a4a7-3b9562f0ff22');

var_dump((string) $affectedVariant); // string(7) "variant2"
```

### Running the Test Suite

[](#running-the-test-suite)

VariantRetriever uses [Pest PHP](https://pestphp.com) as testing framework. Once you have all dependencies installed via `composer install`, you can run the test suite with:

```
./vendor/bin/pest
```

To obtain the code coverage report, you'll need to have `xdebug` installed. Then, you can run:

```
./vendor/bin/pest --coverage
```

And this will give you detailed information about code coverage.

What about speed
----------------

[](#what-about-speed)

VariantRetriever is fast. In our test, we ensure that the retriever is able to get 50 000 variants to randomly generate different identifiables in less than 1 second. Local dev machine can run 500 000 runs in less than a second.

What about randomness
---------------------

[](#what-about-randomness)

RowsRolloutRolloutMax Rollout difference1k50/5046.5/46.53.5%500k50/5049.87/49.870.13%500k10\*109.880.12%500k10/10/809.88/9.88/79.920.12%

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.9% 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 ~18 days

Total

4

Last Release

2017d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.2.5

1.0.2PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a27e3236ea45c2a93f2ef189f37c0c72bfab70f6d73714d396456c6e3d3c25c?d=identicon)[ScullWM](/maintainers/ScullWM)

---

Top Contributors

[![ScullWM](https://avatars.githubusercontent.com/u/1017746?v=4)](https://github.com/ScullWM "ScullWM (15 commits)")[![ferrastas](https://avatars.githubusercontent.com/u/116074?v=4)](https://github.com/ferrastas "ferrastas (3 commits)")[![xelan](https://avatars.githubusercontent.com/u/5080535?v=4)](https://github.com/xelan "xelan (1 commits)")

---

Tags

ab-testingexperimentfeature-flaggingfeature-flagshacktoberfesthacktoberfest-acceptedretrievervariants

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/travaux-com-variantretriever/health.svg)

```
[![Health](https://phpackages.com/badges/travaux-com-variantretriever/health.svg)](https://phpackages.com/packages/travaux-com-variantretriever)
```

PHPackages © 2026

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