# Slim Flash in Middleware

**URL:** https://discourse.slimframework.com/t/slim-flash-in-middleware/1262
**Category:** Questions
**Created:** [March 11, 2017, 11:22am UTC](https://discourse.slimframework.com/t/slim-flash-in-middleware/1262 "2017-03-11T11:22:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![lperry65](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/lperry65/32/333_2.png) [@lperry65](https://discourse.slimframework.com/u/lperry65)
#### Post date: [March 11, 2017, 11:22am UTC](https://discourse.slimframework.com/t/slim-flash-in-middleware/1262/1 "2017-03-11T11:22:59Z")

</div>

Hi,

I’m new to using Slim but have been developing on PHP for a while. I did do a search here first before posting so sorry if this is me missing something simple.

I’v created some middleware using ZF2 ACL, it works fine until I try and DI Slim-Flash into the middleware at which point flash stops working across the app. However it works fine if I change it to router middleware, Ive commented out the flash for now while so I can continue working on the app.

Here is a gist of what I’m doing: [https://gist.github.com/lperry65/b0244ed541513985abaf1a63aa448c31](https://gist.github.com/lperry65/b0244ed541513985abaf1a63aa448c31)

Thanks for your help

---

<div class="post-metadata">

### Author: ![lperry65](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/lperry65/32/333_2.png) [@lperry65](https://discourse.slimframework.com/u/lperry65)
#### Post date: [March 11, 2017, 1:32pm UTC](https://discourse.slimframework.com/t/slim-flash-in-middleware/1262/2 "2017-03-11T13:32:45Z")

</div>

Sorted, changed this in dependencies.php: $view-\>addExtension(new Knlv\Slim\Views\TwigMessages($container[‘flash’]));  
from $view-\>addExtension(new App\Twig\Extensions\CsrfExtension(new Slim\Flash\Messages()));

Hope it helps someone else 😉
