Download the PHP package marilenarm/turbo-toast-bundle without Composer

On this page you can find all versions of the php package marilenarm/turbo-toast-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package turbo-toast-bundle

TurboToastBundle

Flash messages that keep your pages HTTP-cacheable.

Live overview → · Runnable demo app →, where you can click through every session-free flow.

A page that touches the session cannot be stored by a shared HTTP cache: Symfony marks it private, so Varnish or your CDN will never serve it. The classic $this->addFlash() does exactly that. It drags the session (and its lock) into otherwise stateless pages just to display "Item saved", and your anonymous page stops being cacheable because of a one-line notification.

This bundle takes the flash out of the session entirely, with two transports:

On pages that no longer open a session, three things change:

When (not) to use it

Be honest with your profiler before adopting this. The session lock is paid once per request, whatever opens the session:

Profile first (Blackfire: look for session_start and serialized concurrent requests), then decide.

Requirements

Symfony 8 itself requires PHP >= 8.4.1, so that pairing rules out PHP 8.3. The same goes for UX 3, which requires PHP >= 8.4: on PHP 8.3, Composer keeps you on UX 2.

The pairings CI actually runs are listed in MATRIX (see Contributing): a sparse grid hitting both ends of the PHP range each Symfony branch supports, plus a --prefer-lowest run resolving the oldest dependency set the constraints allow.

Symfony 7.0–7.3 are accepted by the version constraint, since nothing in the bundle needs a newer API, but they are not tested: those branches are end-of-life and carry unpatched security advisories, so Composer refuses to install them by default.

Installation

Register the bundle (Flex does it automatically):

Add the toast container to your base layout:

The function renders the container div from the bundle configuration. DOM id, cookie name and Stimulus identifiers are injected from PHP, so a YAML change can never drift apart from the JS side. The rendered markup is data-turbo-permanent (existing toasts survive Turbo Drive navigations) and aria-live="polite" (inserted toasts are announced by screen readers).

[!NOTE] Controllers auto-registered from UX packages get namespaced Stimulus identifiers: marilenarm--turbo-toast--toast and marilenarm--turbo-toast--toast-container. If you need full control over the container markup, write the div manually and keep its Stimulus values in sync with the bundle configuration yourself.

Import the styles if you want them (they are meant to be overridden):

Usage

Use the trait in any controller:

Emit several at once:

To append a row and notify in the same response, include the toast partial in your own *.stream.html.twig:

Not in a controller? Inject MarilenaRM\TurboToastBundle\Toast\ToastRenderer and call ->render(new Toast(...)).

Classic redirects (non-Turbo flows)

When a flow performs a full-page RedirectResponse (post-login redirect, OAuth or payment callbacks, data-turbo="false" links, locale switch...), there is no Turbo Stream to render. Use deferToast() instead: a short-lived cookie carries the toast to the next page load, still without touching the session.

The verb follows what your controller returns, nothing is guessed:

You return Use
a Turbo Stream response toast() / toasts()
a RedirectResponse (or any full page) deferToast() before returning

toast() throws a LogicException when the current request does not accept Turbo Streams (no text/vnd.turbo-stream.html in the Accept header), because a stream rendered there would reach the browser as raw markup. Turbo forms send that header automatically; for anything else, use deferToast().

How the cookie transport behaves:

Each rule answers a concrete failure scenario. The security & hardening design notes walk through the threat model and explain why every protection is there.

Customizing cookie-rendered toasts

Two hooks, both keeping the message XSS-safe (textContent only):

Template — write the container manually (instead of turbo_toast_container()) and put a <template> target inside it. Its root element is cloned per toast, receives the toast--{type} class and the delay value; the message lands in the [data-toast-message] element (or the root when none is declared):

Event — take over rendering entirely by cancelling the marilenarm--turbo-toast--toast-container:append event:

Profiler

In debug mode, a Turbo Toast panel appears in the Symfony profiler: every toast emitted during the request, per transport (Turbo Stream / cookie), with the queued / transported / discarded counts for the cookie path. The traceable decorators are only wired under kernel.debug, so production pays nothing.

Configuration

Contributing

The test pipeline runs in Dagger, so the matrix you run on your laptop is the one CI runs. That closes the "works on my machine" gap, and the Symfony version list is not duplicated in a workflow file. With the Dagger CLI and a container runtime installed:

The tested combinations live in MATRIX, in .dagger/src/turbo_toast/main.py. Each cell pins Symfony through symfony/flex and the UX major through composer update --with, then asserts that both really landed on the versions under test, so a cell cannot go green while quietly resolving a newer Symfony or the other UX major.

Widening the supported range means editing composer.json, adding a row to MATRIX, and updating the Requirements section above plus the version strings in docs/index.html (grep -n 'Symfony 6.4' docs/index.html finds them).


If this bundle saved your pages from the session lock, you can buy me a coffee ☕


All versions of turbo-toast-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
psr/log Version ^3.0
symfony/config Version ^6.4 || ^7.0 || ^8.0
symfony/dependency-injection Version ^6.4 || ^7.0 || ^8.0
symfony/event-dispatcher Version ^6.4 || ^7.0 || ^8.0
symfony/http-foundation Version ^6.4 || ^7.0 || ^8.0
symfony/http-kernel Version ^6.4 || ^7.0 || ^8.0
symfony/service-contracts Version ^3.5
symfony/stimulus-bundle Version ^2.13 || ^3.0
symfony/ux-turbo Version ^2.13 || ^3.0
twig/twig Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package marilenarm/turbo-toast-bundle contains the following files

Loading the files please wait ...