palpalani/laravel-toastr

Implements toastr.js for Laravel projects
24,536 3
Install
composer require palpalani/laravel-toastr
Latest Version:0.4.0
PHP:^8.3
License:MIT
Last Updated:Jun 29, 2026
Links: GitHub  ·  Packagist
Maintainer: palpalani

Laravel Toastr

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Implements toastr.js for Laravel. Toastr.js is a Javascript library for non-blocking notifications.

Installation

NPM

To install a plugin via npm run

npm install toastr

Composer

You can also install the package via composer:

composer require palpalani/laravel-toastr

Configuration

Publish the config file with

php artisan vendor:publish --provider="palPalani\Toastr\ToastrServiceProvider" --tag="laravel-toastr-config"

This is the contents of the published config file:

return [
    'options' => [
        "progressBar" => true,
        "positionClass" =>"toast-bottom-right",
        "preventDuplicates"=> false,
        "showDuration" => 300,
        "hideDuration" => 1000,
        "timeOut" => 5000,
        "extendedTimeOut" => 1000,
        "showEasing" => "swing",
        "hideEasing"=> "linear",
        "showMethod" => "fadeIn",
        "hideMethod" => "fadeOut",
    ]
];

If you want, edit config/toastr.php and set the options array to whatever you want to pass to Toastr (this step is optional). These options are set as the default options and can be overridden by passing an array of options to any of the methods in the Usage section.

Usage

Include jQuery, toastr.js and plugin styles in your master view template.

Link to toastr.min.css:

<link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" rel="stylesheet"/>

Link to toastr.min.js:

<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>

After everything is done, insert the string below in your template just before body closing tag or after toastr.js script instantiated in your file.

{!! Toastr::render() !!}

Then use these methods in your controllers to insert a toast:

  • Toastr::warning($message, $title = null, $options = []) - add a warning toast
  • Toastr::error($message, $title = null, $options = []) - add an error toast
  • Toastr::info($message, $title = null, $options = []) - add an info toast
  • Toastr::success($message, $title = null, $options = []) - add a success toast
  • Toastr::add($type: warning|error|info|success, $message, $title = null, $options = []) - add a toast
  • Toastr::clear() - clear all current toasts don't forget to use it

For a list of available options, see toastr.js' documentation.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

nilsenj/toastr-5.1-laravel

toastr.js for Laravel 5.1/5.2 easy notification like growl for example

34,033 6
brian2694/laravel-toastr

toastr.js for Laravel

794,856 131
oriceon/toastr-5-laravel

Easy toastr notifications for Laravel 5

502,600 79
narutimateum/toastr-5.2-laravel

toastr.js for Laravel 5.2 easy notification like growl for example

37,567 13
whossun/laravel-toastr

toastr.js for laravel 5.2

2,837 4