Slim Flash in Middleware


#1

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

Thanks for your help


#2

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 :wink: