PHPackages                             divineomega/php-bucket-testing - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. divineomega/php-bucket-testing

Abandoned → [jord-jd/php-bucket-testing](/?search=jord-jd%2Fphp-bucket-testing)Library[Testing &amp; Quality](/categories/testing)

divineomega/php-bucket-testing
==============================

This library enables developers to easily redirect users to different URLs, for the purpose of bucket testing. Bucket testing is also known as A/B testing or split testing. This type of testing is used to test two or more versions of a webpage to determine which one performs better based on specfied key metrics, such as clicks, downloads, purchases or any other form of conversion.

v3.0.0(6mo ago)028LGPL-3.0-onlyPHPPHP &gt;=5.3CI passing

Since Mar 21Pushed 4w agoCompare

[ Source](https://github.com/Jord-JD/php-bucket-testing)[ Packagist](https://packagist.org/packages/divineomega/php-bucket-testing)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/divineomega-php-bucket-testing/feed)WikiDiscussions master Synced 4w ago

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

PHP Bucket Testing
==================

[](#php-bucket-testing)

[![Tests](https://github.com/Jord-JD/php-bucket-testing/actions/workflows/tests.yml/badge.svg)](https://github.com/Jord-JD/php-bucket-testing/actions/workflows/tests.yml)[![Packagist](https://camo.githubusercontent.com/2339d9fe9096d8170df7f8127abc16491658ec6c48c82d0f78eb974d4f6fa45b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f72642d6a642f7068702d6275636b65742d74657374696e672e737667)](https://packagist.org/packages/jord-jd/php-bucket-testing)

This library enables developers to easily redirect users to different URLs, for the purpose of bucket testing. Bucket testing is also known as A/B testing or split testing.

This type of testing is used to test two or more versions of a webpage to determine which one performs better based on specified key metrics, such as clicks, downloads, purchases or any other form of conversion.

Features
--------

[](#features)

- Random selection of buckets, with optional weights
- Stable weighted assignment for a user, account, or session identifier
- Automatic handling of temporary redirects
- Ability to retrieve bucket and manually handle URL redirection
- Injectable random-number generation for reproducible tests
- Easy to use fluent interface syntax

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

[](#installation)

To install, just run the following composer command.

`composer require jord-jd/php-bucket-testing`

Remember to include the `vendor/autoload.php` file if your framework does not already do so.

Usage
-----

[](#usage)

```
use \JordJD\BucketTesting\BucketManager;
use \JordJD\BucketTesting\Bucket;

// Create a new bucket manager
$bucketManager = new BucketManager;

// Add buckets, with URLs and optional weights
$bucketManager->add(new Bucket('https://google.co.uk/'))->withWeight(25);
$bucketManager->add(new Bucket('https://php.net/'))->withWeight(75);

// Redirect to a randomly selected URL
$bucketManager->redirect();

// Or replace the call above with another valid 3xx status code:
// $bucketManager->redirect(307);

// Or, if you wish, get a random bucket and manually handle the redirection
$bucket = $bucketManager->getRandomBucket();
header('location: '.$bucket->url);
```

Stable experiment assignments
-----------------------------

[](#stable-experiment-assignments)

For a meaningful A/B test, the same subject should normally stay in the same cohort. Pass a stable, non-empty identifier such as a user ID, account ID, or session ID to `getBucketForSubject()`:

```
$bucket = $bucketManager->getBucketForSubject($userId);
```

The assignment is deterministic and respects the configured weights. It does not require server-side storage, but changing the bucket list, its order, or its weights can change existing assignments.

Deterministic tests
-------------------

[](#deterministic-tests)

You may inject a callable that returns an integer within the requested range. Production code uses `random_int()` when available and falls back to `mt_rand()`on older PHP versions.

```
$bucketManager = new BucketManager(function ($minimum, $maximum) {
    return $minimum;
});
```

Bucket URLs may be absolute or relative, but must be non-empty strings and may not contain carriage-return or newline characters. `redirect()` accepts only integer HTTP status codes from 300 through 399.

Compatibility
-------------

[](#compatibility)

PHP 5.4 through the current PHP 8.x releases are supported. PHP 5.4 is the minimum because the package source has always used short-array syntax.

### Upgrading to 4.0

[](#upgrading-to-40)

Composer now enforces the real PHP 5.4 syntax minimum instead of incorrectly advertising PHP 5.3 support. `Bucket` also rejects empty, non-string, or header-unsafe URL values when constructed. Existing valid bucket URLs and the original random-selection API continue to work unchanged.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance83

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 76.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 ~650 days

Recently: every ~813 days

Total

6

Last Release

181d ago

Major Versions

v1.0.3 → v2.0.02018-09-06

v2.0.0 → v3.0.02026-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/c580cdf7c14898fff179cdfc1085892091d5d2f49d917873a12365af9ac77c93?d=identicon)[Jord-JD](/maintainers/Jord-JD)

---

Top Contributors

[![Jord-JD](https://avatars.githubusercontent.com/u/650645?v=4)](https://github.com/Jord-JD "Jord-JD (10 commits)")[![kirsty-gasston](https://avatars.githubusercontent.com/u/12949343?v=4)](https://github.com/kirsty-gasston "kirsty-gasston (3 commits)")

---

Tags

a-b-testingbucket-testingfrontend-testingsplit-testingtestingui-testingux-testingtestingsplit testinga b testingbucket testingUX testingUI testingfrontend testing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/divineomega-php-bucket-testing/health.svg)

```
[![Health](https://phpackages.com/badges/divineomega-php-bucket-testing/health.svg)](https://phpackages.com/packages/divineomega-php-bucket-testing)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k971.0M165.4k](/packages/phpunit-phpunit)[phpunit/php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.

8.9k951.4M1.8k](/packages/phpunit-php-code-coverage)[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k536.9M28.4k](/packages/mockery-mockery)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k103.4M2.3k](/packages/behat-behat)[symfony/phpunit-bridge

Provides utilities for PHPUnit, especially user deprecation notices management

2.5k216.1M5.4k](/packages/symfony-phpunit-bridge)[brianium/paratest

Parallel testing for PHP

2.5k142.8M1.1k](/packages/brianium-paratest)

PHPackages © 2026

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