PHP code example of live-controls / utils

1. Go to this page and download the library: Download live-controls/utils 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/ */

    

live-controls / utils example snippets


$model = \App\Models\User::find(1);

$variant = \LiveControls\Utils\AB::getVariantForModel($model, 'feature_a');

dd($variant); //Returns either 1 or 2

$variant = 1; //Can also be A or 2/B
$model = \App\Models\User::find(1);

$hasVariant = hasVariant($model, $variant, 'feature_a');

dd($hasVariant); //Would return true if model is inside variant with the selected salt

use \LiveControls\Utils\HasABTests;

$model = \App\Models\User::find(1);
$variant = 1; //Can be either 1/A or 2/B
$salt = 'feature_1'; //Can be a name of the feature you want to check or can be leave out to have it general.
$model->hasVariant($variant, $salt); //Will return true if its the models variant

$model->getVariantForModel($salt); //Returns either 1 or 2, depending on the models variant.
$model->has_variant_a; //Returns true if model has variant a. Does not support a salt.
$model->has_variant_b; //Returns true if model has variant b. Does not support a salt.