PHPackages                             cubicmushroom/symfony-error-redirect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. cubicmushroom/symfony-error-redirect

ActiveLibrary

cubicmushroom/symfony-error-redirect
====================================

Symfony bundle to provide simple redirect with flash messages

0314PHP

Since Jul 29Pushed 11y ago1 watchersCompare

[ Source](https://github.com/toby-griffiths/symfony2-message-redirect-bundle)[ Packagist](https://packagist.org/packages/cubicmushroom/symfony-error-redirect)[ RSS](/packages/cubicmushroom-symfony-error-redirect/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Message Redirect Bundle
=======================

[](#message-redirect-bundle)

Introduction
------------

[](#introduction)

Symfony2 bundle that provides service for conveniently redirecting the user from wherever you are in the call stack, and displaying a message to the user.

It does this by throwing a MessageRedirectException that is then caught by the MessageRedirectListener which adds the message to the session flahsBag, andthen redirects the user to the specified URI.

If a previous exception is passed in to the MessageRedirectException, and the current environment has debugging enabled, then the exception will not trigger a redirect, and the exception will be displayed to the user, including the previous exception thrown.

Installation
------------

[](#installation)

To use this bundle follow these steps...

1. Add the bundle using composer

    ```
     "require": {
         "cubicmushroom/symfony-error-redirect": "dev-master"
     }

    ```
2. Register the bundle in app/AppKernel.php

    ```
     class AppKernel extends Kernel
     {
         // ...

         public function registerBundles()
         {
             $bundles = array(
                 // ...
                 new CubicMushroom\MessageRedirectBundle\CubicMushroomMessageRedirectBundle(),
             );

             // ...

             return $bundles;
         }

         // ...
     }

    ```
3. Add the message template to your view template (probably best at the base template level to avoid having ot remember to each view

    ```
     {{ include('CubicMushroomMessageRedirectBundle:elements:message.html.twig') }}

    ```

    To add your own classes to the flash messages, define the flashClasses twig variable before calling the inlude

    ```
     {% set flashClasses = 'alert' %}
     {{ include('CubicMushroomMessageRedirectBundle:elements:message.html.twig') }}

    ```

Usage
-----

[](#usage)

### Redirect

[](#redirect)

There are 1 ways to rediect...

1. Use the service's createRedirectWithMessage() method and returning this from your controller.

    ```
     // If within object with a Container object
     return $this->container->get('message_redirect')->createRedirectWithMessage( $uri, $message, $messageClass );

    ```
2. Create and throw a RedirectMessageException

    ```
     // If within object with a Container object
     thrown $this->container->get('message_redirect')->createRedirectException(
         $uri,
         $message,          // optional
         messageType,       // optional
         $previousException // optional
     );

    ```

### Using different Exception class to redirect

[](#using-different-exception-class-to-redirect)

To use your own exception class for the redirects, simply set the %message\_redirect.exception.message\_redirect.class% parameter to another exception class that implements the \\CubicMushroom\\MessageRedirectBundle\\Exception\\MessageRedirectExceptionInterface interface

To use your own exception on for a single request, you can set the exception class on the service by doing the following...

```
$this->container->get('message_redirect')->setMessageRedirectExceptionClass( $class );
// Then call createRedirectWithMessage() to create the exception to throw

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b156769d704438a2a9e79cd9f7b7a01c8a7b17a191b389469ae55de8f0c982a6?d=identicon)[ToG](/maintainers/ToG)

---

Top Contributors

[![toby-griffiths](https://avatars.githubusercontent.com/u/4817007?v=4)](https://github.com/toby-griffiths "toby-griffiths (30 commits)")

### Embed Badge

![Health badge](/badges/cubicmushroom-symfony-error-redirect/health.svg)

```
[![Health](https://phpackages.com/badges/cubicmushroom-symfony-error-redirect/health.svg)](https://phpackages.com/packages/cubicmushroom-symfony-error-redirect)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
