PHP code example of stagem / zfc-flash

1. Go to this page and download the library: Download stagem/zfc-flash library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stagem / zfc-flash example snippets


$app->pipe(\Stagem\ZfcFlash\FlashMiddleware::class);

use Psr\Http\Server\RequestHandlerInterface;
use Zend\Diactoros\Response\RedirectResponse;

function($request, RequestHandlerInterface $handler)
{
    $flash = $request->getAttribute('flash');
    $flash->addMessage('Hello World!', 'success');

    return new RedirectResponse('/other-middleware');
}

// view/widget/flash-messages.phtml
#$flash = $this->current('request')->getAttribute('flash');
$messages = $flash->getAllMessages();
// iterate over array 

return [
    'templates' => [
        'paths' => [
            'widget' => [__DIR__ . '/../view/widget'],
        ],
    ],
];