PHPackages                             paaa14/c-flash-message - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. paaa14/c-flash-message

ActiveLibrary

paaa14/c-flash-message
======================

Adding a Flash-Message function

v1.0(10y ago)022PHPPHP &gt;=5.3.0

Since Mar 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/patrikalbertsson/CFlashMessage)[ Packagist](https://packagist.org/packages/paaa14/c-flash-message)[ RSS](/packages/paaa14-c-flash-message/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

CFlashMessage
=============

[](#cflashmessage)

[![build:passed](https://camo.githubusercontent.com/f8370fe0a9cf0783371e3795fe3f54bfcb2ec2ea852dd41f2d31072350b85487/68747470733a2f2f7472617669732d63692e6f72672f70617472696b616c6265727473736f6e2f43466c6173684d6573736167652e737667)](https://camo.githubusercontent.com/f8370fe0a9cf0783371e3795fe3f54bfcb2ec2ea852dd41f2d31072350b85487/68747470733a2f2f7472617669732d63692e6f72672f70617472696b616c6265727473736f6e2f43466c6173684d6573736167652e737667)

[![Scrut](https://camo.githubusercontent.com/30939b677ebce6ae919a177e8750a3046cf871e65019e268c856eb397f2c898a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70617472696b616c6265727473736f6e2f43466c6173684d6573736167652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://camo.githubusercontent.com/30939b677ebce6ae919a177e8750a3046cf871e65019e268c856eb397f2c898a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70617472696b616c6265727473736f6e2f43466c6173684d6573736167652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)

[![CodeCoverage](https://camo.githubusercontent.com/752700a4a7b0f17b7b475552ae93ea1ebaf2c4b3dd4e6be3d0ed542e3e1140a5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70617472696b616c6265727473736f6e2f43466c6173684d6573736167652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://camo.githubusercontent.com/752700a4a7b0f17b7b475552ae93ea1ebaf2c4b3dd4e6be3d0ed542e3e1140a5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70617472696b616c6265727473736f6e2f43466c6173684d6573736167652f6261646765732f636f7665726167652e706e673f623d6d6173746572)

This is an module for simple flash-messages. It contains in general three functions:

`setFlash('type', 'message')`: Types allowed: success, notice, warning and error.

`hasFlash()`: Returns true if flash is set, else false.

`getFlash()`: Get flashMessage.

How to use CFlashMessage
------------------------

[](#how-to-use-cflashmessage)

### 1. Install via composer

[](#1-install-via-composer)

Install CFlashMessage via packagist and composer. Add

```
"require": {
    "php": ">=5.4",
    "paaa14/c-flash-message" : "dev-master"
},

```

in your `composer.json`.

### 2. Set FlashMessage-class

[](#2-set-flashmessage-class)

Set flashMessage in your base class implementing Dependency Injection / Service Locator- file. If you are using Anax-MVC, ex.

File:`src/DI/CDIFactoryDefault.php`

Add `$this->setShared('flashMessage', '\Anax\FlashMessage\CFlashMessage')` (you maybe want to change the namespace for `CFlashMessage.php`)

### 3. Implement code in your template-file

[](#3-implement-code-in-your-template-file)

File: `theme/anax-base/index.tpl.php`

In your div#main, put code:

```

```

to see if flash has been set. If it returns true, show flashMessage.

Exemple:

```

```

### 4. Add stylesheet

[](#4-add-stylesheet)

Copy `flash.css` to your css-archive and be sure that `flash.css` is activated in your framework.

### 5. Session

[](#5-session)

Be sure that Sessions is activated in your framework. If you `var_dump($_SESSION)` you should have an empty session. If you are using Anax-MVC you might have to start the session manually i your frontcontroller.

Put `$app->session()` in the top of your controller, after you assign `$app`

### 6. Router

[](#6-router)

Make sure your framework handles routes. If you are using Anax-MVC, put `$app->router->handle()` in the bottom of your frontcontroller, before it's being sent to render.

### 7. Create routes and use FlashMessage

[](#7-create-routes-and-use-flashmessage)

Exemple in Anax-MVC:

```
$app->router->add('', function() use ($app) {
    $app->flashMessage->setFlash('success', "Success! Update page to make this message disappear.");
    $app->views->addString('Flash is set, click on the link to view the flash', 'main');
    $app->views->addString("Link", 'main');
});

$app->router->add('flash', function() use($app) {
    $app->views->addString('In your template-file, there is a if-statement that checks if a flash has been set. If it returns TRUE, this message is shown. Update page to remove this message.');
});

```

To get Anax-MVC, visit:

Enjoy :)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3705d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7fb3b9ab5fc894ef4dabce279cc54e35fb9381c54ef8827834526cf45b8c24a1?d=identicon)[patrikalbertsson](/maintainers/patrikalbertsson)

---

Top Contributors

[![patrikalbertsson](https://avatars.githubusercontent.com/u/11553757?v=4)](https://github.com/patrikalbertsson "patrikalbertsson (31 commits)")

### Embed Badge

![Health badge](/badges/paaa14-c-flash-message/health.svg)

```
[![Health](https://phpackages.com/badges/paaa14-c-flash-message/health.svg)](https://phpackages.com/packages/paaa14-c-flash-message)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
