PHPackages                             sayful1/slim-flash - 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. [Framework](/categories/framework)
4. /
5. sayful1/slim-flash

AbandonedArchivedLibrary[Framework](/categories/framework)

sayful1/slim-flash
==================

Easy flash notifications using sweetAlert for Slim Framework 3

1.0.1(8y ago)014MITPHP &gt;=5.5.0

Since Jan 23Pushed 8y agoCompare

[ Source](https://github.com/57-Wolve/slim-flash)[ Packagist](https://packagist.org/packages/sayful1/slim-flash)[ Docs](http://slimframework.com)[ RSS](/packages/sayful1-slim-flash/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Easy Flash Messages for Slim Framework 3
========================================

[](#easy-flash-messages-for-slim-framework-3)

This repository contains a Slim Framework Flash messages service provider. This enables you to define transient messages that persist only from the current request to the next request.

Install
-------

[](#install)

Via Composer

```
$ composer require sayful1/slim-flash
```

Requires Slim 3.0.0 or newer.

Usage
-----

[](#usage)

```
// Start PHP session
session_start();

$app = new \Slim\App();

// Fetch DI Container
$container = $app->getContainer();

// Register provider
$container['flash'] = function () {
    return new \Sayful\SlimFlash\Flash();
};

$app->get('/foo', function ($req, $res, $args) {
    // Set flash message for next request
    $this->flash->success('Test', 'This is a message');

    // You may also do
    $this->flash->info('Info!', 'This is info message.');
    $this->flash->warning('Warning!', 'This is warning message.');
    $this->flash->error('Title', 'This is error message.');

    // All method can also take on parameter
    $this->flash->success('This is message without title.');

    // Redirect
    return $res->withStatus(302)->withHeader('Location', '/bar');
});

$app->get('/bar', function ($req, $res, $args) {
    // Get flash messages from previous request
    $messages = $this->flash->getMessages();
    print_r($messages);

    // Get the first message
    $test = $this->flash->getFlashMessage();
    print_r($test);
});

$app->run();
```

Behind the scenes, this will set a few keys in the session:

- 'flash\_message'
- 'flash\_message\_overlay'

Add flash as global variable to Twig-View. For Twig-View, see documentation on [Slim Framework Twig View](https://github.com/slimphp/Twig-View)

```
$container['view'] = function ($container) {
    ...
    // Add flash as global variable to twig view
    $view->getEnvironment()->addGlobal( 'flash', $container->flash );
    ...
};
```

With this message flashed to the session, you may now display it in your view(s). Maybe something like with twig-view package:

```
{% if flash.getFlashMessage() %}

        {% if flash.getFlashMessage.message %}
        swal({
            title: "{{ flash.getFlashMessage.title }}",
            text: "{{ flash.getFlashMessage.message }}",
            icon: "{{ flash.getFlashMessage.label }}",
            button: false,
            timer: 2000
        });
        {% else %}
        swal({
            text: "{{ flash.getFlashMessage.title }}",
            icon: "{{ flash.getFlashMessage.label }}",
            button: false,
            timer: 2000
        });
        {% endif %}

{% endif %}
```

> Note that this package is optimized for use with [sweetAlert](https://sweetalert.js.org/).

You can also implement this package with [Bootstrap](http://getbootstrap.com/)

```
{% if flash.getFlashMessage() %}
    {% if flash.getFlashMessage.message %}

            &times;
            {{ flash.getFlashMessage.title }}
            {{ flash.getFlashMessage.message }}

    {% else %}

            &times;
            {{ flash.getFlashMessage.title }}

    {% endif %}
{% endif %}
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

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

Every ~0 days

Total

2

Last Release

3030d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f6610e4c9adecd41d90744ddc0aaf69c31a9c65338a78a6373164348ba767c2c?d=identicon)[57-Wolve](/maintainers/57-Wolve)

---

Top Contributors

[![sayful1](https://avatars.githubusercontent.com/u/6873334?v=4)](https://github.com/sayful1 "sayful1 (5 commits)")

---

Tags

messageframeworkslimproviderflash

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sayful1-slim-flash/health.svg)

```
[![Health](https://phpackages.com/badges/sayful1-slim-flash/health.svg)](https://phpackages.com/packages/sayful1-slim-flash)
```

###  Alternatives

[slim/flash

Slim Framework Flash message service provider

1522.2M99](/packages/slim-flash)[kanellov/slim-twig-flash

A Twig extension to access Slim Flash messages in templates

22107.6k9](/packages/kanellov-slim-twig-flash)[slim/twig-view

Slim Framework 4 view helper built on top of the Twig 3 templating component

3708.0M210](/packages/slim-twig-view)[gotzmann/comet

Modern PHP framework for building blazing fast REST APIs and microservices

68816.2k1](/packages/gotzmann-comet)[rubellum/slim-blade-view

Slim Framework 3 view helper built on the Blade component

1822.4k2](/packages/rubellum-slim-blade-view)[podcastcrawler/podcastcrawler

PHP library to find podcasts

402.7k1](/packages/podcastcrawler-podcastcrawler)

PHPackages © 2026

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