yiirocks / toast-bootstrap5
Bootstrap 5 toast notifications backed by Yii3 session flash messages
Fund package maintenance!
Requires
- php: >=8.3
- psr/container: ^1.0 || ^2.0
- yiisoft/html: ^3.9 || ^4.0
- yiisoft/session: ^3.0
- yiisoft/yii-view-renderer: ^7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: @stable
- httpsoft/http-message: @stable
- infection/infection: ^0.34.0
- phpunit/phpunit: @stable
- vimeo/psalm: ^6.0
- yiirocks/svg-inline: ^1.0
- yiirocks/svg-inline-bootstrap: ^1.0
- yiisoft/config: ^1.6
- yiisoft/di: *
Suggests
- yiirocks/svg-inline-bootstrap: Renders an icon in each toast, resolved via yiirocks/svg-inline-bootstrap or another registered icon set.
This package is auto-updated.
Last update: 2026-08-03 19:46:59 UTC
README
Bootstrap 5 toast notifications for Yii framework 3.0, backed by
yiisoft/session flash messages. Queue a message from a
controller, echo $toast in your layout, done - no manual partials, no custom JS.
Stats for Nerds
Requirements
- PHP 8.3+
- Bootstrap 5's JS bundle loaded on the page (for dismiss/autohide behavior)
Installation
The package could be installed via composer:
composer require yiirocks/toast-bootstrap5
Optionally, add Bootstrap Icons per message type:
composer require yiirocks/svg-inline-bootstrap
Usage
Queue a message from a controller or anywhere else FlashToastInterface is available:
public function __construct(private FlashToastInterface $toast) {} public function actionSave(): ResponseInterface { // ... $this->toast->success('Changes saved.'); return $this->redirect('...'); }
Then echo $toast once in your layout - the default configuration injects it into every view:
<?= $toast ?>
Nothing renders until a message is pending. Four types are available (success, error,
warning, info), each mapped to a Bootstrap 5 text-bg-* color, and multiple messages of the
same type stack as separate toasts.
Available options (auto-hide delay per type, icon per type, container position) can be found in the documentation.
Unit testing
The package is tested with Psalm, PHPUnit and Infection mutation testing. To run tests:
composer psalm composer phpunit composer infection