Crater PHP Framework

fast, lightweight and modular

Flash Messenger

The Flash Messenger is a plugin designed to create and retrieve self-expiring, session-based messages

How to use

There are several types of messages:

  • info $this->flashMessage->info($message)
  • success $this->flashMessage->success($message)
  • warning $this->flashMessage->warning($message)
  • error $this->flashMessage->error($message)

Is very simple to use. In your controller you must have something like:

public function indexAction()
{
    // Check if request method is post
    if ($this->isPost()) {
        // Business logic

        // Set an info flash message
        $this->flashMessage->info('This is an info flash message!');
    }

    return $this->view->render('index/index');
}

In your template (or in view) you must have something like:

<?php if ($fm = $this->getFlashMessage()): ?>
    <div class="flash-message <?php echo $fm['type'] ?>">
        <p><strong><?php echo ucfirst($fm['type']) ?>:</strong> <?php echo $fm['message'] ?></p>
    </div>
<?php endif ?>