Download the PHP package communitales/status-bus without Composer
On this page you can find all versions of the php package communitales/status-bus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download communitales/status-bus
More information about communitales/status-bus
Files in communitales/status-bus
Package status-bus
Short Description Communitales StatusBus Component
License MIT
Homepage https://www.communitales.com
Informations about the package status-bus
Communitales StatusBus Component
Publish status messages without coupling application code to their presentation. Messages can be sent to a PSR-3 logger, a Symfony session flash bag, or any custom handler.
Status delivery is synchronous and best-effort. A failing handler does not affect the calling application or prevent other handlers from receiving the message.
Installation
Usage
Inject StatusBusInterface and publish an immutable StatusMessage:
message can be either a literal message or a translation key. The available
factory methods are success(), info(), warning(), and error().
Translation parameters and the translation domain are presentation data.
context contains structured diagnostic data for handlers such as the PSR-3
logger and is not shown in flash messages.
Symfony configuration
The following configuration sends every status message to the application logger and to the Symfony flash bag:
Remove either handler registration if only one destination is required.
The log handler maps status levels as follows:
| Status | PSR-3 level |
|---|---|
success |
notice |
info |
info |
warning |
warning |
error |
error |
When a translator is injected, log messages are translated using the optional
locale configured on PsrLogStatusHandler. The original message, domain,
parameters, and level remain available below the status_message context key.
The flash handler stores a TranslatableMessage instead of rendering it early.
Translate the message when displaying it:
The flash handler performs the presentation-specific mapping from status error
to Bootstrap flash type danger.
Delivery failures
LogAndContinueDeliveryFailureHandler is the production strategy. It reports a
failed delivery through a PSR-3 logger and lets the bus continue with the next
handler. It also suppresses logger failures, preserving fire-and-forget behavior.
Use RethrowDeliveryFailureHandler in development or tests when handler failures
should fail immediately:
InMemoryStatusHandler is available for tests and exposes received messages via
messages().
Custom handlers
Handlers should throw when delivery fails. StatusBus applies the configured
failure strategy and decides whether processing continues.
All versions of status-bus with dependencies
psr/log Version ^3.0
symfony/http-foundation Version ^7.4|^8.1
symfony/translation Version ^7.4|^8.1
symfony/translation-contracts Version ^3.6