PHPackages                             ntpages/laravel-taster - 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. ntpages/laravel-taster

AbandonedArchivedLibrary

ntpages/laravel-taster
======================

Laravel package for A/B testing

15.2k↓50%1PHP

Since Jul 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ntpages/laravel-taster)[ Packagist](https://packagist.org/packages/ntpages/laravel-taster)[ RSS](/packages/ntpages-laravel-taster/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Taster
==============

[](#laravel-taster)

If you're cooking new features for your Laravel app or just want to know what tastes better this package is definitely for you!

First steps
-----------

[](#first-steps)

1. Install the package
    `composer require ntpages/laravel-taster`
2. Register service provider
    `Ntpages\LaravelTaster\Provider::class` in the `config/app.php`
3. Run the migrations
    `php artisan migrate`
4. Publish package files
    ` php artisan vendor:publish`

Structure
---------

[](#structure)

The logic of the package is based on three models, Experiment, Variant and Interaction. All of them are stored in the database on tables with `tsr_` prefix. All three have a unique key and name in order to be easily identifiable in the code or user interface.

### Experiment

[](#experiment)

It is a unit that groups different types of variants to easily split traffic and statistics between them. Variants hardly depends on it, which means if you are building a UI where you can create/delete experiments deleting one would clear all related data.

### Variant

[](#variant)

It's an instance that represents one way to seeing the experiment. There's one important thing to be aware of, and it's the `portion` attribute. It represents the approximate percentage of visitors that should reach the variant. So you can have as many variants as you need in one experiment as long as their portions sum 1, the total amount of visitors.

In order to not lose any data about experiments when there's available portion a default variant is created.

#### Interactions

[](#interactions)

The simplest unit that helps to keep track and compare the performance of the experiment variants.

Usage
-----

[](#usage)

In this section you'll see different approaches that can be used with this package.

### Build in helpers

[](#build-in-helpers)

This package provides a set of functions used to config &amp; track your experiments.

#### Front-end

[](#front-end)

This is the most common way of usage. Using the next structure you can be sure it'll work as expected you should only know the keys of the currently enabled experiments and their variants.

```
@experiment('pet-preferences')

    @variant('no-pet')
        How to have a pet
    @endvariant

    @variant('cat-lover')
        This cats are smashing the day
    @endvariant

    @variant('dog-lover')
        Dogs are better than humans
    @endvariant

@endexperiment
```

**How to track interactions?**
It's as simple as just adding needed attributes to the element you want to track and including the javascript assets.\\

> IMPORTANT: these helpers can only be used inside of `@variant` blade directive.

When using the `tsrAttrs` helper you'll need to add the package javascripts. You can do that however you want, but the recommended way is deferring the script loading.

```

```

Another important thing about `tsrAttrs` helper is that you'll always need a html elements so if you don't have one just create an empty div. Have in mind that the only event that will make sense in that case is `view`.

```
@experiment('expertiment-1')

   {{-- other variants --}}

    @variant('variant-1')
        Page
    @endvariant

@endexperiment
```

> There are some special cases in the html, when the tag has its own actions executed by the browser. For that just use an extra wrapper.

```

      Login

```

The package also provides the possibility of generation of the interaction URL in case you need it somewhere else.

```
@experiment('expertiment-1')

   {{-- other variants --}}

    @variant('variant-1')
        Page

            const interactionUrl = '{{ tsrUrl('interaction-key') }}';
            // do something with that URL

    @endvariant

@endexperiment
```

### From within PHP

[](#from-within-php)

There are sometimes when you can capture interactions on back-end. It's always a good idea as that way you're not overloading the front-end with extra javascript from the package. For that you can access to `TasterService` right inside of Laravel application by using the `app()` helper or using a dependency injection technique.

```
use Illuminate\Support\Facades\Log;

use Ntpages\LaravelTaster\Exceptions\AbstractTasterException;
use Ntpages\LaravelTaster\Services\TasterService;

class FooController
{
    public function barAction(TasterService $taster)
    {
        try {
            // interaction for whatever variant user sees
            $taster->record('experiment-key', 'interaction-1-key');

            // granular settings depending on variant
            $taster->record('experiment-key', [
                'variant-1-key' => 'interaction-1-key',
                'variant-2-key' => [
                    'interaction-1-key',
                    'interaction-2-key'
                ]
            ]);
        } catch (AbstractTasterException $e) {
            Log::error('Taster says: ' . $e->getMessage());
        }

        return view('foo.bar');
    }
}
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.3% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b75f50341d141c5233a9f2ec2df8a55ce2f190bba629c4a0735c2467079768e?d=identicon)[ntpages](/maintainers/ntpages)

---

Top Contributors

[![anstapol](https://avatars.githubusercontent.com/u/33395021?v=4)](https://github.com/anstapol "anstapol (36 commits)")[![VictorGarcia](https://avatars.githubusercontent.com/u/204441?v=4)](https://github.com/VictorGarcia "VictorGarcia (1 commits)")

---

Tags

laravel

### Embed Badge

![Health badge](/badges/ntpages-laravel-taster/health.svg)

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

PHPackages © 2026

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