# Toastr in Laminas

**URL:** <https://discourse.laminas.dev/t/toastr-in-laminas/2202>\
**Category:** Components & MVC\
**Tags:** laminas-mvc, mvc-plugin-flashmessenger\
**Created:** [March 24, 2021, 8:38am UTC](https://discourse.laminas.dev/t/toastr-in-laminas/2202 "2021-03-24T08:38:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kriss\_Kals](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/kriss_kals/32/1295_2.png) [@Kriss\_Kals](https://discourse.laminas.dev/u/Kriss_Kals)\
**Post date:** [March 24, 2021, 8:38am UTC](https://discourse.laminas.dev/t/toastr-in-laminas/2202/1 "2021-03-24T08:38:38Z")

</div>

Hello!  
Do you use toastr in your projects? Could someone please share their experience?

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [March 24, 2021, 9:13am UTC](https://discourse.laminas.dev/t/toastr-in-laminas/2202/2 "2021-03-24T09:13:17Z")

</div>

Do you mean [GitHub - CodeSeven/toastr: Simple javascript toast notifications](https://github.com/CodeSeven/toastr) ?

---

<div class="post-metadata">

**Author:** ![Kriss\_Kals](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/kriss_kals/32/1295_2.png) [@Kriss\_Kals](https://discourse.laminas.dev/u/Kriss_Kals)\
**Post date:** [March 24, 2021, 10:52am UTC](https://discourse.laminas.dev/t/toastr-in-laminas/2202/3 "2021-03-24T10:52:57Z")

</div>

Exactly. I would like to apply this alongside flashMessenger - return some messages using only flash, and some using **flash and toastr**. For Laravel, there are many examples of how to do it nice and easy - but for Laminas, I couldn’t find anything…

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [March 24, 2021, 12:15pm UTC](https://discourse.laminas.dev/t/toastr-in-laminas/2202/4 "2021-03-24T12:15:18Z")

</div>

> [@Kriss\_Kals](#):
>
> For Laravel, there are many examples of how to do it nice and easy…

You mean calling `toastr()->info('Hello World')` in controller is nice? And what if the frontend changes tomorrow? Do you want to rewrite everything because a different library is used, like [Bootstrap with Toasts](https://getbootstrap.com/docs/5.0/components/toasts/) or the next hype on the framework market? 😉

> [@Kriss\_Kals](#):
>
> I would like to apply this alongside flashMessenger - return some messages using only flash, and some using **flash and toastr**.

I think you can use [custom namespace for setting the message](https://github.com/laminas/laminas-mvc-plugin-flashmessenger/blob/91bc10e43cf3afcfe4ffbcc7aa0382af51430e75/src/FlashMessenger.php#L156) for different output on the plugin. Then the output of these messages must be customised. This can be done by overwriting the related view helper.

---

<div class="post-metadata">

**Author:** ![Kriss\_Kals](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/kriss_kals/32/1295_2.png) [@Kriss\_Kals](https://discourse.laminas.dev/u/Kriss_Kals)\
**Post date:** [March 25, 2021, 7:44am UTC](https://discourse.laminas.dev/t/toastr-in-laminas/2202/5 "2021-03-25T07:44:40Z")

</div>

@froschdesign Thanks for the tips and for your patience. I wanted to provoke some other people into discussion with the mention of Laravel 😂

I generally used flashMessenger with the namespace variable:

```
$this->flashMessenger()->setNamespace('toast_error')->addMessage('article_create_error');

```

or

```
$this->flashMessenger()->setNamespace('toast_success')->addMessage('article_create_success');

```

And in my helper I display the appropriate message depending on the toast type.

```
if($this->flashMessenger()->hasMessages('toast_success')):

```

I hope this is a good solution.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [March 25, 2021, 7:54am UTC](https://discourse.laminas.dev/t/toastr-in-laminas/2202/6 "2021-03-25T07:54:22Z")

</div>

> [@Kriss\_Kals](#):
>
> I wanted to provoke some other people into discussion with the mention of Laravel

Don’t worry, the problem can also be found in other systems. 😉

> [@Kriss\_Kals](#):
>
> ```auto
> $this->flashMessenger()->setNamespace('toast_error')->addMessage('article_create_error');
> 
> ```

Or:

```php
$this->flashMessenger()->addMessage('article_create_error', 'toast_error');

```

> [@Kriss\_Kals](#):
>
> I hope this is a good solution.

👍
