tilttek / dice-probability-bundle
tilttek/dice-probability in Symfony: the odds of a dice expression in Twig, as an accessible table and chart, updated live as it is typed.
Package info
github.com/TiltTek/dice-probability-bundle
Type:symfony-bundle
pkg:composer/tilttek/dice-probability-bundle
Requires
- php: >=8.5
- phil/rate-limit: ^0.1.1@dev
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- tilttek/dice: ^0.2@dev || ^0.3@dev
- tilttek/dice-bundle: ^0.2@dev
- tilttek/dice-probability: ^0.1.4@dev
Requires (Dev)
- phil/ux-kit: >=0.1.0-alpha <1.0
- phpunit/phpunit: ^13.4
- symfony/cache: ^8.2
- symfony/event-dispatcher: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-foundation: ^8.2
- symfony/http-kernel: ^8.2
- symfony/rate-limiter: ^8.2
- symfony/routing: ^8.2
- symfony/stimulus-bundle: ^3.7
- symfony/translation: ^8.2
- symfony/twig-bridge: ^8.2
- symfony/twig-bundle: ^8.2
- symfony/ux-live-component: ^3.7
- symfony/ux-twig-component: ^3.7
- symfony/yaml: ^8.2
- twig/twig: ^3.21
Suggests
- ext-gmp: To write the long fractions of the probabilities in their lowest terms
- phil/ux-kit: For the recipes the table, the chart and the component are drawn with, installed by the Symfony UX Toolkit
- symfony/rate-limiter: For the rate limit of <twig:TilttekDiceProbability:Distribution>, on by default: required with symfony/ux-live-component unless "rate_limit.enabled" is false
- symfony/translation: To translate the words of the table, the chart and the component
- symfony/twig-bundle: For the Twig functions and the table and chart of the probabilities, with symfony/ux-twig-component
- symfony/ux-live-component: For the probabilities on a page, <twig:TilttekDiceProbability:Distribution>, with symfony/ux-twig-component
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-21 03:06:04 UTC
README
The probabilities of dice expressions on a Symfony page: a table that is always there, a chart, and a component that computes as you type.
tilttek/dice-probability-bundle integrates tilttek/dice-probability with Symfony. It reads the expressions with the
DiceRoller of tilttek/dice-bundle — its notations, limits and custom dice —, takes the depth of explosions, the work
limit, the estimates and the rounding from the configuration, and gives DiceStatistics for expressions written as
text. In templates, Twig functions give a distribution or a comparison, and draw them as a summary, a bar chart and an
accessible table; the Live Component TilttekDiceProbability:Distribution does the same as an expression, and a second
one to compare it with, are typed. The screens are drawn with the recipes of the PHIL UX kit, which the application
installs with the Symfony UX Toolkit.
Anyone may type into the component, so the bundle bounds the work of every request: the limits of the library, a weight of the groups an estimate searches checked before any die is rolled, a cap on the rows of a table, fractions reduced within a bounded work, and a rate limit on the component per IPv4 address or IPv6 /64, on by default.
Status
| Part | State |
|---|---|
| Configuration: explosion depth, work limit, samples, seed, rounding, bounds of a request | Implemented and tested |
DiceStatistics: distributions, comparisons and events of expressions written as text |
Implemented and tested |
Groups too long to search refused before the estimate, GroupSearch |
Implemented and tested |
| Twig functions, filter with a bounded reduction, table and chart, in English and French | Implemented and tested |
| Live Component, with the refusals of the bundle translated | Implemented and tested |
| Rate limit of the Live Component per IPv4 address or IPv6 /64, on by default | Implemented and tested |
| Screens drawn with the recipes of the PHIL UX kit, in the Toolkit's subdirectory | Implemented and tested |
Events of chance() in Twig and in the component |
Not started |
| Languages other than English and French | Not started |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, optional packages, registering the bundle and installing the recipes of the kit. |
| Configuration | Every key, its default and what it sets; the search of groups and the rate limit. |
| Statistics in PHP | DiceStatistics and Rounding. |
| Templates | The Twig functions, the table and the chart, their accessibility, and the component. |
| Extension points | Overriding the templates, adding a language, events of the application. |
| Testing | The bundle's tests, and how to test pages that show probabilities. |
| Reference | Every type and service of the bundle. |
Quick start
composer require tilttek/dice-probability-bundle
// config/bundles.php return [ Tilttek\DiceBundle\TilttekDiceBundle::class => ['all' => true], Tilttek\DiceProbabilityBundle\TilttekDiceProbabilityBundle::class => ['all' => true], ];
php bin/console ux:install alert card chart field input radio-group table --kit=github.com/parler-haut-interagir-librement/ux-kit
{{ tilttek_dice_probabilities('4d6kh3') }}
<twig:TilttekDiceProbability:Distribution expression="1d20+5" versus="2d10+4" />
Requirements
PHP 8.5 or later, Symfony 8.2, tilttek/dice-probability and tilttek/dice-bundle; Twig, the translator, Symfony UX
and the recipes of the PHIL UX kit for the templates and the component, with symfony/rate-limiter for its rate limit;
ext-gmp for the long fractions.
Contributing
Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.
License
MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Tilttek project. See LICENSE.