tilttek / exchange-bundle
tilttek/exchange in Symfony: members redeem rewards, give points and trade items, kept in the database with forms, safeguards and expiry.
Package info
github.com/TiltTek/exchange-bundle
Type:symfony-bundle
pkg:composer/tilttek/exchange-bundle
Requires
- php: >=8.5
- doctrine/dbal: ^4.5
- phil/resource: ^0.1@dev
- psr/event-dispatcher: ^1.0
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- tilttek/exchange: ^0.2@dev
- tilttek/points: ^0.2@dev
Requires (Dev)
- doctrine/doctrine-bundle: ^3.3
- doctrine/orm: ^3.7
- phil/privacy-bundle: ^0.1@dev
- phpunit/phpunit: ^13.4
- psr/clock: ^1.0
- symfony/clock: ^8.2
- symfony/console: ^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
- tilttek/points-bundle: ^0.2@dev
Suggests
- doctrine/orm: To add the exchanges' tables to the schema the ORM generates, and so to the migrations
- phil/privacy-bundle: To export and erase a member's exchanges with the rest of their account
- symfony/console: For the commands that expire the reservations and the offers and show the journal of transfers
- symfony/form: For the forms that reserve a reward, give points and make an offer
- tilttek/points-bundle: For the Points and Currencies services the exchanges spend, give and refund through; an application may register its own instead
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-21 03:09:02 UTC
README
Rewards, gifts of points and trades of items for a Symfony application's members, kept in the database.
tilttek/exchange-bundle integrates tilttek/exchange with Symfony, on the points of tilttek/points-bundle. It keeps
the reservations, the journal of transfers and the offers with the items they hold in tables on a Doctrine DBAL
connection, added to the schema the ORM generates so that the application's migrations create them, and the catalogue
of rewards in the configuration or in a table the application edits. It builds Redemptions from the configuration,
the PointsHold contract that holds, keeps and gives back the points of a reserved reward,
and Transfers and Trades when the application enables them, with their guards — an allowance per period, a delay
for new accounts —, checked when the container is compiled. The steps of a trade run in one transaction of the
connection, the ledger of points included when it is kept there. The events reach the application's event dispatcher,
where a listener delivers the rewards; three forms reserve a reward, give points and make an offer; a command expires
the reservations and the offers, another shows the journal of transfers; a module answers the export and erasure
requests of phil/privacy-bundle for a member's exchanges.
It is for a Symfony application whose members spend their points on rewards, give them to each other or trade the items of their collections, and wants each exchange written once, all or nothing.
It requires Symfony's DependencyInjection and Config, Doctrine DBAL, the PSR event dispatcher, tilttek/exchange,
tilttek/points and phil/resource, and the Points and Currencies services that tilttek/points-bundle registers.
The ORM, the Console, the Form component and phil/privacy-bundle are optional: the schema listener, the commands, the
forms and the privacy module are registered only when they are installed.
The design follows the other bundles of the monorepo: an AbstractBundle with its configuration, services declared by
ExchangeServices, DBAL stores and stores in memory for tests, tables added by a schema listener.
Status
| Part | State |
|---|---|
Configuration tilttek_exchange: store, connection, catalogue, rewards, lifetimes, conditions, joining dates, timezone, transfers, trades, member kind |
Implemented and tested |
DbalCatalog, DbalReservationStore, DbalTransferLog, DbalOfferStore and DbalTransaction, with their seven tables |
Implemented and tested |
Moments stored in UTC by the type datetime_utc_immutable |
Implemented and tested |
| The DBAL stores on SQLite, MySQL 8.4 and PostgreSQL 17 | Implemented and tested |
| The tables in the schema the ORM generates, for the migrations | Implemented and tested |
PointsHold, the points of a reserved reward held, kept or given back, and SpendingPointsHold on Points |
Implemented and tested |
| The events through the application's dispatcher | Implemented and tested |
Forms RedeemRewardType, TransferPointsType and OfferType |
Implemented and tested |
Commands tilttek:exchange:expire and tilttek:exchange:transfers |
Implemented and tested |
Export and erasure of a member for phil/privacy-bundle |
Implemented and tested |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, enabling the bundle, the migration. |
| Configuration | Every key of tilttek_exchange, with its default. |
| Rewards | The catalogue, reserving from a controller, delivering from the event, the scheduled expiry, the points a reservation holds. |
| Transfers and trades | Enabling them, their guards, the inventory, the joining dates. |
| The exchanges in the database | The tables, the locks and holds, the idempotent insertions per platform, the transaction. |
| Events | Listening to the exchanges' events. |
| Forms | The three forms and their data. |
| Commands | tilttek:exchange:expire and tilttek:exchange:transfers. |
| Privacy | The export and the erasure of a member's exchanges. |
| Extension points | The services, aliases and tags the application uses. |
| Exceptions | What the bundle raises. |
| Testing | The bundle's tests, on SQLite, MySQL and PostgreSQL, and how to test an application that exchanges. |
| Reference | Every class of the bundle, with its role. |
Quick start
composer require tilttek/points-bundle tilttek/exchange-bundle
# config/packages/tilttek_exchange.yaml tilttek_exchange: rewards: discount-10: { price: 100 } seat: { price: 250, stock: 30, per_member: 1 } transfers: enabled: true allowance: { limit: 500, period: week }
use Phil\Resource\ResourceReference; use Tilttek\Exchange\Reservation\Redemptions; final readonly class BookSeat { public function __construct(private Redemptions $redemptions) {} public function __invoke(int $memberId, string $orderId): void { $this->redemptions->reserve(ResourceReference::of('member', (string) $memberId), 'seat', 'order:'.$orderId.':seat'); } }
Then bin/console doctrine:migrations:diff writes the migration of the tables, and a scheduler runs
bin/console tilttek:exchange:expire.
Requirements
PHP 8.5 or later, Symfony 8.2, Doctrine DBAL 4.5.
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.