tilttek / dice-bundle
Symfony dice on tilttek/dice: configured limits, custom dice and notations, a Doctrine journal of replayable rolls by member and table, an event per roll, macros by site, table and member, verifiable rolls, a form field and constraint, Twig filters and functions, accessible roll details, and an exte
Requires
- php: >=8.5
- doctrine/orm: ^3.7
- phil/resource: ^0.1@dev
- psr/clock: ^1.0
- psr/event-dispatcher: ^1.0
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- tilttek/dice: ^0.1@dev || ^0.2@dev
Requires (Dev)
- doctrine/dbal: ^4.5
- doctrine/doctrine-bundle: ^3.3
- phpunit/phpunit: ^13.4
- symfony/clock: ^8.2
- symfony/event-dispatcher: ^8.2
- symfony/form: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/http-kernel: ^8.2
- symfony/options-resolver: ^8.2
- symfony/translation: ^8.2
- symfony/translation-contracts: ^3.6
- symfony/twig-bundle: ^8.2
- symfony/validator: ^8.2
- twig/twig: ^3.21
Suggests
- symfony/form: For the DiceExpressionType field
- symfony/translation: To translate the words of a roll and the labels of the faces
- symfony/twig-bundle: For the filters, the functions and the detail of a roll in templates
- symfony/validator: For the DiceExpression constraint
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-15 03:21:45 UTC
README
Dice for a Symfony application: configured, rolled, kept to be replayed, checked in forms and shown in templates.
tilttek/dice-bundle integrates tilttek/dice with Symfony. It builds the library from the configuration — its limits,
the custom dice of the application, the notations of more languages —, rolls from a secure source, keeps replayable
rolls in a Doctrine journal — by member and by table, each one announced by an event — and replays them, keeps the
macros of a site, a table and a member, makes verifiable rolls, and gives a form field with its constraint, Twig
filters and functions, and an accessible detail of a roll. An extension point dresses a member's dice with the
appearance of a set they own — colour, ink, material, texture —, and the numbers always read on it. It does not animate
dice, draw the roller's page, decide who may roll, nor own any dice set: the application does.
It is for Symfony applications that roll dice for their members: a dice roller page, a play-by-post forum, a character
sheet, a game table. An application without Symfony takes tilttek/dice alone.
It is an AbstractBundle on Symfony 8.2 with Doctrine ORM 3. The form type, the constraint and the Twig extension are
registered only when Symfony Form, Validator and Twig are installed. A member is an opaque ResourceReference of
phil/resource: the bundle reads no name, address or account.
The design is small: the bundle class reads the configuration, DiceServices registers the services, DiceRolls is the
service the application calls, DiceMacros keeps and resolves macros, RecordedRoll is a row of the journal,
RollRecorded announces it, and DiceAppearance is the port that dresses a member's dice.
Status
| Part | State |
|---|---|
| Configuration: limits, custom dice, notations, appearance, translation domain, store, entity manager | Implemented and tested |
DiceRolls: parse, read DiceParser, write, translate, roll, replayable rolls, replay, verifiable rolls and verification, a member's rolls and their erasure |
Implemented and tested |
| Journal of replayable rolls in Doctrine, or in memory: context of a roll, rolls by owner, by context and many at once | Implemented and tested |
RollRecorded event |
Implemented and tested |
DiceMacros: macros of a site, a table and a member, named by token, in Doctrine or in memory |
Implemented and tested |
DiceAppearance extension point: colour, ink, material, image, texture; an ink that reads at 4.5:1 when none is given; the viewer's high contrast |
Implemented and tested |
DiceExpression constraint and DiceExpressionType field |
Implemented and tested |
Twig: dice_notation, dice_dialect, dice_roll, dice_roll_detail, dice_text |
Implemented and tested |
| Dialects added by tag | Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, registering the bundle, the journal's table. |
| Configuration | Every option of tilttek_dice, with its default. |
| Rolling | DiceRolls: plain, replayable and verifiable rolls, the journal and its contexts, erasing a member's rolls. |
| Macros | DiceMacros: the shelves of a site, a table and a member, defining, resolving and erasing macros. |
| Forms and validation | DiceExpressionType and the DiceExpression constraint. |
| Templates | The Twig filters and functions, the detail of a roll, its classes and its words. |
| Extension points | DiceAppearance and the readable ink, dialects by tag, the journal's port, RollRecorded. |
| Exceptions | What the bundle raises. |
| Testing | The bundle's tests, and how to test an application that rolls dice. |
| Reference | Every type of the bundle, with its role. |
| Upgrading | From 0.1 to 0.2: the context column, the journal's port, the appearance. |
Quick start
composer require tilttek/dice-bundle
# config/packages/tilttek_dice.yaml tilttek_dice: custom_dice: coin: faces: - { id: heads, label: 'Heads', value: 1, shape: circle } - { id: tails, label: 'Tails', value: 0, shape: square }
use Tilttek\DiceBundle\Application\DiceRolls; public function __invoke(DiceRolls $dice): Response { $recorded = $dice->rollReplayable('4d6kh3 + 1d{coin}'); return $this->render('dice/roll.html.twig', ['replay' => $dice->replay($recorded->id())]); }
{{ dice_roll_detail(replay.result) }}
Requirements
PHP 8.5 or later, Symfony 8.2, Doctrine ORM 3.7, tilttek/dice and phil/resource 0.1. Symfony Form, Validator, Twig
and Translation are optional.
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.