class IndexController extends AbstractActionController
{
public function indexAction()
{
$this->notices()->addSuccessMessage('You successfully read this important alert message.');
$this->notices()->addInfoMessage('This alert needs your attention, but it\'s not super important.');
$this->notices()->addWarningMessage('Better check yourself, you\'re not looking too good.');
$this->notices()->addErrorMessage('Change a few things up and try submitting again.');
}
}
Output:, (*5)
Well done!
You successfully read this important alert message.
Heads up!
This alert needs your attention, but it's not super important.
Warning!
Better check yourself, you're not looking too good.
Oh snap!
Change a few things up and try submitting again.
How to configure
You can customize the output template, turn off escaping and change the label of messages.
To do this, add to config file (config/autoload/global.php):, (*6)