PHP code example of mislant / flash

1. Go to this page and download the library: Download mislant/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/ */

    

mislant / flash example snippets


public function someAction()
{
    # here is some business logic
    $flashGenerator = new FlashGenerator(
        SetterInterface::class # your storage setter implementation
    );
    
    # end of business logic
    if ($businessResult) {
        $flashGenerator->success('Everything is Ok');
        return $businessResult;
    }
    $flashGenerator->error('Something goes wrong');
    return $businessResult;
}

public function showAlerts()
{
    $flashExtractor = new FlashExtractor(
        GetterInterface::class # your getter from storage implementation
    );
    
   # Your render logic
   $messages = $flashExtractor->info();
   foreach ($messages as $message){
       showAlert($message);
   }
}