1. Go to this page and download the library: Download abrouter/laravel-abtest 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/ */
abrouter / laravel-abtest example snippets
use Abrouter\LaravelClient\Bridge\KvStorage;
use Abrouter\LaravelClient\Bridge\ParallelRunning\TaskManager;
return [
'token' => '14da89de1713a74c1ed50aafaff18c24bf372a9913e67e6a7a915def3332a97c9c9ecbe2cd6d3047',
'host' => 'https://abrouter.com',
'parallelRunning' => [
'enabled' => true, //parallel running, enabled by default. See next section.
'taskManager' => TaskManager::class,
],
'kvStorage' => KvStorage::class
];
use Abrouter\Client\Client;
class ExampleController
{
public function __invoke(Client $client)
{
$userId = auth()->user()->id;
$buttonColor = $client->experiments()->run($userId, 'button_color');
return view('button', [
'color' => $buttonColor->getBranchId(),
]);
}
}
use Abrouter\Client\Client;
class ExampleController
{
public function __invoke(Client $client)
{
$isEnabledButton = $client->featureFlags()->run('enabled_button_feature_flag');
return view('featureFlags', [
'enabledButtonFeatureFlag' => $isEnabledButton,
]);
}
}
use Abrouter\Client\Client;
use Abrouter\Client\Builders\StatEventBuilder;
class ExampleController
{
public function __invoke(Client $client, StatEventBuilder $statEventBuilder)
{
$userId = auth()->user()->id;
//sending button_click event as button_click+1
$client->statistics()->sendEvent(
$eventBuilder
->incremental()
->event('button_click')
->setUserId($userId)
->build()
);
//sending purchase event with purchase amount (+30)
$client->statistics()->sendEvent(
$eventBuilder
->summarize()
->event('purchase')
->setValue(30)
->setUserId($userId)
->build()
);
}
}
bash
php artisan vendor:publish --tag=abrouter
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.