PHP code example of ananiaslitz / item-balancer

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

    

ananiaslitz / item-balancer example snippets

 

use Ananiaslitz\ItemBalancer\RedisCache;
use Ananiaslitz\ItemBalancer\Distributor;

$categories = ['A', 'B'];
$percentages = [70, 30];
$cache = new RedisCache();
$distributor = new Distributor($cache, $categories, $percentages);

$result = $distributor->distribute('ItemX');
print_r($result);