PHP code example of dmt-software / ab-middleware

1. Go to this page and download the library: Download dmt-software/ab-middleware 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/ */

    

dmt-software / ab-middleware example snippets


use DMT\AbMiddleware\AbService;
use DMT\AbMiddleware\AbPsrMiddleware;

// define your experiments
$experiments = [
    'active-experiment' => [
        'variant-1' => 0.3,
        'variant-2' => 0.3,
        'control' => 0.4,
    ],
    'old-experiment' => [
        'variant-1' => 0.3,
        'variant-2' => 0.3,
        'control' => 0.4,
    ],
];

// instantiate the service
$service = new AbService($experiments);

// instantiate the middleware
$abMiddleware = new AbPsrMiddleware($service, 'ab-uid-cookie-name');

// add the middleware to your middleware stack