PHP code example of graymatterlabs / experiment

1. Go to this page and download the library: Download graymatterlabs/experiment library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

graymatterlabs / experiment example snippets


$manager = new Manager($persistence, $factory, $strategy);
$sample = new Sample();

$allocation = $manager->allocate($experiment, $sample);

if (! $allocation->isAllocated()) {
    // unable to allocate
}

if ($allocation->isVariant('TEST')) {
    // execute experimental feature
}

if ($allocation->wasRecentlyAllocated) {
    // the allocation is new
}