I'd like to setup flash message(slim/flash). I saw the reference here. I made the following middleware to register flash message.
use Interop\Http\ServerMiddleware\DelegateInterface;
use Zend\Diactoros\Response\RedirectResponse;
function($request, DelegateInterface $delegate)
{
$flash = $request->getAttribute('flash');
$flash->addMessage('message', 'Hello World!');
return new RedirectResponse('/other-middleware');
}
and the question is how to get this flash message from view templates? The reference wrote here but I'm not sure where should I put this code and how to show the flash.
use Interop\Http\ServerMiddleware\DelegateInterface;
function($request, DelegateInterface $delegate)
{
$flash = $request->getAttribute('flash');
$messages = $flash->getMessages();
// ...
}
Thank you for your help.