Here is a how you can display all your flash bag messages in a Symfony Twig view.  The “flash bag” is a special collection of session variables that hold data like a one-time message in HTML.  It is often used in e-commerce form flows when the credit card was declined, instead of further processing the payment, the rejection of the credit card appears in your TWIG view so the user can read the message and act on it.

Perhaps it will say “Credit card was denied, please check your billing ZIP code.”  or another frequent issue happens when the user fails to put in the appropriate number of credit card digits, you can have your controller put in the flash bag the message:  “Credit card requires 15 digits for AMEX, 16 digits for all other cards.”

{% for label, flashes in app.session.flashbag.all %}

    {% for flash in flashes %}

        <div class="alert alert-{{ label }}">

            {{ flash }}


    {% endfor %}

{% endfor %}


Here is a quick way to access all request variables and output them in a Symfony Twig view:

{% for request in app.request.query.all  %}
   {{ request|raw }}<br/>
{% endfor %}