Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lxg's avatar
Level 1

How to use toastr js in Laravel?

Im trying to use toast notifications by toastr in my Laravel web Application, which usage is described here: https://github.com/yoeunes/toastr. I did everything in the tutorial but i can not display a message.

I typed this => {!! app('toastr')->render() !!} into my Layout file to show the message.

When i instead use {{ app('toastr')->render() }} in my layout file, this is show on my webpage

  "closeButton": true,
  "closeClass": "toast-close-button",
  "closeDuration": 300,
  "closeEasing": "swing",
  "closeHtml": "<button><i class=\"icon-off\"><\/i> <
    \/button>","closeMethod":"fadeOut","closeOnHover":true,"containerId":"toast-container","debug":false,"escapeHtml":false,"extendedTimeOut":10000,"hideDuration":1000,"hideEasing":"linear","hideMethod":
  "fadeOut",
  "iconClass": "toast-info",
  "iconClasses": {
    "error": "toast-error",
    "info": "toast-info",
    "success": "toast-success",
    "warning": "toast-warning"
  },
  "messageClass": "toast-message",
  "newestOnTop": false,
  "onHidden": null,
  "onShown": null,
  "positionClass": "toast-top-right",
  "preventDuplicates": true,
  "progressBar": true,
  "progressClass": "toast-progress",
  "rtl": false,
  "showDuration": 300,
  "showEasing": "swing",
  "showMethod": "fadeIn",
  "tapToDismiss": true,
  "target": "body",
  "timeOut": 5000,
  "titleClass": "toast-title",
  "toastClass": "toast"
};
toastr.success('hi', '', []);```
 
Does anyone have an idea why nothing is shown with this usage=> {!! app('toastr')->render() !!}. Shouldn't that work when with this usage=> {{ app('toastr')->render() }} the javascript is shown?
Is there a problem with composer?
0 likes
5 replies
Snapey's avatar

Did you do this bit

Include jQuery and toastr.js in your view template:

Link to jquery or from cdn with our custom blade directive @jquery

Link to toastr.css or @toastr_css

Link to toastr.js or @toastr_js

If you are using the default app.js then jquery is already loaded

Make sure you monitor the browser console for any issues.

lxg's avatar
Level 1

It tells me Failed to load resource: the server responded with a status of 404 () for toastr.js and toastr.css and that toastr is not defined

Is this stuff not included by composer? Is this a proxy problem possibly?

lxg's avatar
Level 1

@yoeunes yes, i am using your notify package now it works fine now, thx :)

1 like
yoeunes's avatar

cool, you're welcome, thanks for using it ^^

Please or to participate in this conversation.