1. Go to this page and download the library: Download orchid/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/ */
orchid / experiment example snippets
$ composer
use Orchid\Experiment\Experiment;
$experiment = new Experiment();
// Distribution
$ab = $experiment->start([
'A' => 1,
'B' => 1,
]); // A or B
use Orchid\Experiment\Experiment;
use Illuminate\Support\Facades\Cache;
$storage = Cache::store('redis');
$experiment = new Experiment('my-key', $storage);
$ab = $experiment->start([
'A' => 50,
'B' => 100,
]); // A or B
namespace App\Http\Middleware;
use Closure;
use Orchid\Experiment\Experiment;
class Experiments
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
* @throws \Exception
*/
public function handle($request, Closure $next)
{
$experiment = new Experiment('AB');
$experiment->startAndSaveCookie([
'A' => 50,
'B' => 50,
]);
return $next($request);
}
}
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
class EncryptCookies extends Middleware
{
/**
* The names of the cookies that should not be encrypted.
*
* @var array
*/
protected $except = [
'AB'
];
}