PHPackages                             zunnu/cake-toastr - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. zunnu/cake-toastr

ActiveCakephp-plugin[Mail &amp; Notifications](/categories/mail)

zunnu/cake-toastr
=================

A CakePHP plugin for integrating Toastr notifications.

1.0.1(1y ago)172MITPHPPHP &gt;=8.1

Since Aug 5Pushed 1y ago2 watchersCompare

[ Source](https://github.com/zunnu/cake-toastr)[ Packagist](https://packagist.org/packages/zunnu/cake-toastr)[ RSS](/packages/zunnu-cake-toastr/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

cake-toastr
===========

[](#cake-toastr)

This package was created primarily for personal use. It allows you to easily integrate Toastr messages into your CakePHP application

Installing Using [Composer](http://getcomposer.org)
---------------------------------------------------

[](#installing-using-composer)

`cd` to the root of your app folder (where the `composer.json` file is) and run the following command:

```
composer require zunnu/cake-toastr

```

Then load the plugin by using CakePHP's console:

```
./bin/cake plugin load CakeToastr

```

Note the flash component does not need to be loaded but you need to have flash render in your layout.

```

```

Usage
-----

[](#usage)

### Loading the Component

[](#loading-the-component)

Load the component you will need to modify your `src/Controller/AppController.php` and load the toastr component in the `initialize()` function

```
$this->Flash = $this->loadComponent('CakeToastr.Toastr', ['alias' => 'Flash']);
```

### Loading the Helper

[](#loading-the-helper)

Sure, you could load the view helper anywhere you like—like in a random controller or buried deep inside a view. But if you actually want things to work smoothly, and, you know, avoid a headache, just load it in the layout where it belongs. Because who doesn't love clean, maintainable code, right?

```
$this->loadHelper('CakeToastr.Toastr', ['progressBar' => true]);
```

See? Super simple. And if you're feeling extra fancy and want to tweak the options, go ahead and generate them from [this magical place](https://codeseven.github.io/toastr/demo.html).

### Using Flash Messages

[](#using-flash-messages)

From a controller, you can call it like a normal flash message:

```
$this->Flash->warning('This is a custom success message');
```

This simple setup allows you to start using Toastr notifications with default settings. If you'd like to customize the behavior, you can pass additional options.

### Customizing Toastr Notifications

[](#customizing-toastr-notifications)

#### Using Callbacks

[](#using-callbacks)

You can customize the behavior of Toastr notifications using JavaScript callbacks such as `onShown`, `onShow`, `onHide`, and `onHidden`. For example, if you want to execute custom JavaScript when a toast is fully displayed, you can use the `onShown` callback.

Here's how to use the `onShown` callback:

```
$this->loadHelper('CakeToastr.Toastr', [
    'positionClass' => 'toast-bottom-center',
    'callbacks' => [
        'onShown' => 'function() {
            console.log("Toastr notification displayed");
        }'
    ]
]);
```

This setup logs a message to the console when the toast is shown.

#### Injecting Custom CSS

[](#injecting-custom-css)

You can also inject custom CSS to style your Toastr notifications. For instance, if you want to adjust the minimum width and position of your toast messages, you can pass custom CSS as follows:

```
$this->loadHelper('CakeToastr.Toastr', [
    'positionClass' => 'toast-bottom-center',
    'customCss' => '
        .toast-bottom-center {
            bottom: 8%;
        }
        .toast-bottom-center .toast {
            min-width: 600px;
        }
    ',
    'callbacks' => [
        'onShown' => 'function() {
            console.log("Custom styles applied and Toastr notification shown");
        }'
    ]
]);
```

This will ensure that the toast messages have a minimum width of 600px and are positioned 8% from the bottom of the screen.

### Putting It All Together

[](#putting-it-all-together)

Combine callbacks and custom CSS for a fully customized experience:

```
$this->loadHelper('CakeToastr.Toastr', [
    'positionClass' => 'toast-bottom-center',
    'customCss' => '
        .toast-bottom-center {
            bottom: 8%;
        }
        .toast-bottom-center .toast {
            min-width: 600px;
        }
    ',
    'callbacks' => [
        'onShown' => 'function() {
            $(".toast-bottom-center .toast").css("background-color", "#333");
            console.log("Custom background color applied and Toastr notification shown");
        }'
    ]
]);
```

In this example, the toast background color is dynamically changed to a custom color when the toast is shown.

License
-------

[](#license)

Licensed under [The MIT License](http://www.opensource.org/licenses/mit-license.php).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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

698d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/87be5ff062749fe4a745840ccf9921ca94a513983363abd7b925248f0c632769?d=identicon)[zunnu](/maintainers/zunnu)

---

Top Contributors

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

---

Tags

cakephpcakephp-pluginflash-messagesnotificationsphptoastr

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zunnu-cake-toastr/health.svg)

```
[![Health](https://phpackages.com/badges/zunnu-cake-toastr/health.svg)](https://phpackages.com/packages/zunnu-cake-toastr)
```

###  Alternatives

[cakephp/debug_kit

CakePHP Debug Kit

86314.7M171](/packages/cakephp-debug-kit)[cakephp/bake

Bake plugin for CakePHP

11212.0M202](/packages/cakephp-bake)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308954.9k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M44](/packages/dereuromark-cakephp-ide-helper)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

3361.0M51](/packages/dereuromark-cakephp-tools)[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

131240.2k13](/packages/dereuromark-cakephp-tinyauth)

PHPackages © 2026

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