PHPackages                             phillipsharring/handlr-module-ab - 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. phillipsharring/handlr-module-ab

ActiveLibrary[Testing &amp; Quality](/categories/testing)

phillipsharring/handlr-module-ab
================================

A/B testing module for handlr apps -- deterministic variant assignment, event capture, and results.

0.1.0(yesterday)00MITPHPPHP &gt;=8.4

Since Jun 27Pushed yesterdayCompare

[ Source](https://github.com/phillipsharring/handlr-module-ab)[ Packagist](https://packagist.org/packages/phillipsharring/handlr-module-ab)[ RSS](/packages/phillipsharring-handlr-module-ab/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

handlr-module-ab
================

[](#handlr-module-ab)

A/B testing module for [handlr](https://github.com/phillipsharring/handlr-mono) apps. Deterministic, session-scoped variant assignment; a `{{#ab}}` Handlebars helper for variant markup; and conversion capture with aggregated daily counts.

Install
-------

[](#install)

```
composer require phillipsharring/handlr-module-ab
npm install @phillipsharring/handlr-module-ab
```

One module, two manifests, lockstep version. Composer installs the PHP backend (service provider, pipes, tables, migrations); npm installs the frontend (Handlebars helper + client runtime).

Setup
-----

[](#setup)

**1. Register the service provider** in `backend/app/config.php`:

```
'providers' => [
    // ...
    Handlr\Module\Ab\AbServiceProvider::class,
],
```

This auto-registers the routes (under the app's existing `api.public` and `api.admin` junctions) and the migrations. Seed data (which tests exist) stays app-owned.

**2. Wire the frontend** in your app entry (e.g. `frontend/src/app.js`):

```
import Handlebars from 'handlebars';
import { registerAbHelpers, ab } from '@phillipsharring/handlr-module-ab';

registerAbHelpers(Handlebars);   // enables {{#ab "test" "variant"}}…{{/ab}}
ab.init();                       // fetch assignments + wire conversion capture
```

**3. Run the migrations** to create the `ab_tests` and `ab_events` tables:

```
composer run migrate
```

What's included
---------------

[](#whats-included)

### Backend (`Handlr\Module\Ab\`)

[](#backend-handlrmoduleab)

Routes registered on the app's junctions:

MethodPathJunctionPipeGET`/api/ab/assignments``api.public``GetAbAssignments`POST`/api/ab/capture``api.public``CaptureAbEvent`GET`/api/admin/ab``api.admin``GetAbTests`POST`/api/admin/ab``api.admin``PostCreateAbTest`GET`/api/admin/ab/{id}``api.admin``GetAbTestResults`PATCH`/api/admin/ab/{id}``api.admin``PatchUpdateAbTest`- `AbService` — deterministic `assignVariant()` (crc32 of session + test name), assignment lookup, and event recording.
- `ab_tests` / `ab_events` table migrations (auto-discovered via `migrationPaths()`). Seed data (which tests to run) is app-owned — define it in your app's seeds against `Handlr\Module\Ab\Data\AbTestsTable`.
- Dispatches the `ab.event.captured` event (`AbEventCapturedEvent`) on each capture, so apps can listen.

### Frontend

[](#frontend)

- `registerAbHelpers(Handlebars)` — the `{{#ab "test" "variant"}}…{{/ab}}` block helper.
- `ab.init()` — fetches assignments once per page lifetime, re-applies after boosted navigation, and delegates `data-ab-capture` clicks.
- `capture(event)` / `getAssignments()` — programmatic conversion tracking.

Markup conventions:

```

Original CTA
New CTA

Sign up
```

Removal
-------

[](#removal)

1. Remove `AbServiceProvider::class` from `config.php`.
2. Remove the `registerAbHelpers` / `ab` imports from the app entry.
3. `composer remove phillipsharring/handlr-module-ab` and `npm uninstall @phillipsharring/handlr-module-ab`.
4. Roll back the migrations (or drop the `ab_events` and `ab_tests` tables).

Requires
--------

[](#requires)

- `phillipsharring/handlr-backend` ^0.8 (the framework release where A/B was extracted out of core)
- `@phillipsharring/handlr-frontend` ^0.8 (peer — provides `apiFetch` and the boosted-nav lifecycle hooks)

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11220?v=4)[Phil Harrington](/maintainers/phillipsharring)[@phillipsharring](https://github.com/phillipsharring)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/phillipsharring-handlr-module-ab/health.svg)

```
[![Health](https://phpackages.com/badges/phillipsharring-handlr-module-ab/health.svg)](https://phpackages.com/packages/phillipsharring-handlr-module-ab)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14228.7M340](/packages/dms-phpunit-arraysubset-asserts)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8219.1M69](/packages/orchestra-workbench)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)

PHPackages © 2026

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