PHP code example of ethtezahl / dice-roller

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

    

ethtezahl / dice-roller example snippets


// First: import needed class
use Ethtezahl\DiceRoller\CupFactory;

// Factory allow us to create dice cup.
$factory = new CupFactory();

// We create the cup that will contain the two die:
$cup = $factory->newInstance('2D6');

// Display the result:
echo $cup->roll();

$cup = $factory->newInstance('3D20+D4');