PHP code example of opensoft / rollout

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

    

opensoft / rollout example snippets


use Opensoft\Rollout\Rollout;
use Opensoft\Rollout\Storage\ArrayStorage;

$rollout = new Rollout(new ArrayStorage());

$rollout->isActive('chat', $user);  // returns true/false

$rollout->isActive('chat'); // returns true/false

$rollout->activateGroup('chat', 'all');

$rollout->defineGroup('caretakers', function(RolloutUserInterface $user = null) {
  if (null === $user) {
    return false;
  }

  return $user->isCaretaker(); // boolean
});

$rollout->deactivateGroup('chat');

$rollout->activateUser('chat', $user);

$rollout->deactivateUser('chat', $user);

$rollout->activatePercentage('chat', 20);

crc32($user->getRolloutIdentifier()) % 100 < $percentage

$rollout->deactivatePercentage('chat');

$rollout->deactivate('chat');

$rollout->remove('chat');