PHPackages                             joshbruce/php-dice-tower - 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. joshbruce/php-dice-tower

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

joshbruce/php-dice-tower
========================

A PHP library for rolling various dice and get various results

0.0.6(5y ago)2132MITPHPPHP ~7

Since Nov 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/joshbruce/php-dice-tower)[ Packagist](https://packagist.org/packages/joshbruce/php-dice-tower)[ GitHub Sponsors](https://github.com/8fold)[ GitHub Sponsors](https://github.com/joshbruce)[ RSS](/packages/joshbruce-php-dice-tower/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

Dice Tower
==========

[](#dice-tower)

A PHP library for "rolling" *n* dice, with *n* sides each.

Generates [cryptographic random integers](https://www.php.net/manual/en/function.random-int.php) for unbiased results.

Installation
------------

[](#installation)

```
composer require joshbruce/php-dice-tower

```

Usage
-----

[](#usage)

Say you are rolling a character for an RPG using a fairly standard method (4d6, drop the lowest).

```
use JoshBruce\DiceTower\DicePool;

DicePool::roll4d6()->highest(3)->sum();
// step 1: [3, 5, 2, 1]
// step 2: [5, 3, 2]
// step 3: 10
```

You do not need to use the magic static method:

```
use JoshBruce\DiceTower\DicePool;

DicePool::roll(4, 6)->highest(3)->sum();
// step 1: [3, 5, 2, 1]
// step 2: [5, 3, 2]
// step 3: 10
```

You can also roll a single die using one of the following:

```
use JoshBruce\DiceTower\DicePool;

DicePool::roll();
// rolls 1d6

DicePool::roll(1, 6);
// rolls 1d6

use JoshBruce\DiceTower\Dn;

Dn::withSides();
// roll 1 die with the given number of sides
```

The values of the rolls are calculated at instantiation. Therefore, the various fluent methods are about manipulating the initial results or retrieving values from them.

Details
-------

[](#details)

Effectively this is a random number generator using cryptographic random integers suitable for use where unbiased results are critical ([`random_int`](https://www.php.net/manual/en/function.random-int.php)). The minimum value is always 1.

Inspired by [AnyDice](https://anydice.com) and driven by the desire to create an [MORPG](https://en.wikipedia.org/wiki/Massively_multiplayer_online_role-playing_game) using various dice-based systems; specifically [7DSystem](http://www.7dsystem.com) and the [Cypher System](http://cypher-system.com).

Other
-----

[](#other)

See the .github directory for various details including code of conduct, contribution notes, and so on.

### Contributing

[](#contributing)

See [Contributing](https://github.com/joshbruce/php-dice-tower/blob/master/.github/CONTRIBUTING.md) documentation for general contribution notes.

1. Fork this repo
2. Check out repo using [GitHub Desktop](https://desktop.github.com) or Terminal
3. Verify [Composer](https://getcomposer.org) is installed: `~ composer --version`
4. `~ cd /path/to/repo`
5. `~ composer install`
6. Wait until complete
7. `~ ./vendor/bin/phpunit` (if you have `phpunit` available globally that is okay)
8. All tests should pass

Make desired alterations and [submit a PR](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

2099d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7787b6872cff33c6c0162d6cb4ee841c1a75adcce1b4d4efff759dbbf0d08d30?d=identicon)[itsjoshbruce](/maintainers/itsjoshbruce)

---

Top Contributors

[![joshbruce](https://avatars.githubusercontent.com/u/15252830?v=4)](https://github.com/joshbruce "joshbruce (14 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/joshbruce-php-dice-tower/health.svg)

```
[![Health](https://phpackages.com/badges/joshbruce-php-dice-tower/health.svg)](https://phpackages.com/packages/joshbruce-php-dice-tower)
```

###  Alternatives

[firegento/fastsimpleimportdemo

Wrapper for Magento2 ImportExport functionality, which imports products and customers from arrays

2942.2k](/packages/firegento-fastsimpleimportdemo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
