PHPackages                             zero-config/d - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zero-config/d

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zero-config/d
=============

Dice rolling library

2.0.0(9y ago)025[1 issues](https://github.com/ZeroConfig/D/issues)1Apache-2.0PHPPHP ^7.0

Since Feb 11Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ZeroConfig/D)[ Packagist](https://packagist.org/packages/zero-config/d)[ RSS](/packages/zero-config-d/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (3)Used By (1)

Introduction
============

[](#introduction)

**D** is a dice rolling library. It allows for implementations of dice rolling applications and logic.

See also [zero-config/d-roll](https://github.com/ZeroConfig/D-Roll), an application implementing **D**.

Installation
============

[](#installation)

```
composer require zero-config/d:^2.0
```

Entities
========

[](#entities)

The library implements the following entities:

EntityResultImplementsRole`D``RoleInterface``DieInterface`Represents a single die.`Roll``int``RoleInterface`Represents the outcome of a die roll.`Dice``RoleIteratorInterface`, `DieInterface``DiceInterface`, `DieIteratorInterface`Represents multiple dice. It can roll for them at once or iterate over them.The entity that represents a die is called `D` because `die` is a reserved keyword in the language and it matches with the shorthand name given to it by players all over the world.

Services
========

[](#services)

The library implements the following services:

ServiceResultImplementsRole`Interpreter``DiceInterface``DiceInterpreterInterface`Interpret user input into a set of dice.`RollIterator``RollInterface``RollIteratorInterface`Iterate over rolls.Factories
=========

[](#factories)

The library implements the following factories:

FactoryResultImplements`DieFactory``DieInterface`, `DiceInterface``DieFactoryInterface`, `DiceFactoryInterface``RollFactory``RollInterface``RollFactoryInterface`Number generator
================

[](#number-generator)

The number generator comes from the [hylianshield/number-generator](https://github.com/HylianShield/number-generator)package by implementing its interface, the number generator can be swapped out.

Use case
========

[](#use-case)

You may want to use a different number generator, because the default number generator is not random enough to your taste. Let's see what is needed to create an implementation with a custom number generator:

```
