PHP code example of rurounize / laminas-flash-noty-messenger

1. Go to this page and download the library: Download rurounize/laminas-flash-noty-messenger 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/ */

    

rurounize / laminas-flash-noty-messenger example snippets


return [
    // ...
    'FlashNotyMessenger'
    // ...
]

return [
    // ...
    'noty_config' => [
        'layout'    => 'topRight',
        'theme'     => 'mint',
        'closeWith' => ['click', 'button'],
        /* 'animation' => [
            'open'  => 'animated fadeInRight',
            'close' => 'animated fadeOutRight'
        ] */
    ],

    'noty_assets' => [
        'use'   => 'cdn', // local for local assets
        'cdn'   => [
            'css'   => 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.css',
            'js'    => 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js',
        ],
        'local' => [
            'css'   => 'css/noty/noty.min.css',
            'js'    => 'js/noty/noty.min.js',
        ]
    ],
    // ...
];


/**
 * The fire() method do
 *     Collect all messages from previous and current request
 *     clear current messages because we will show it
 *     add JS files
 *     add JS notifications
 */
 $this->flashNoty()->fire(); 


$this->flashMessenger()->addSuccessMessage('Success message, bravo!');
$this->flashMessenger()->addErrorMessage('Error with system, contact us.');
$this->flashMessenger()->addInfoMessage('Info message, to do whatever...');
$this->flashMessenger()->addWarningMessage('Warning message to be careful.');