PHPackages                             sangamkatwal/sangam-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. sangamkatwal/sangam-toastr

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

sangamkatwal/sangam-toastr
==========================

A simple Laravel package for Toastr notifications with support for session flash messages and AJAX responses. Handles success, error, warning, and info notifications seamlessly.

v1.0.1(9mo ago)05MITBladePHP &gt;=8.0

Since Aug 26Pushed 9mo agoCompare

[ Source](https://github.com/143Sangam143/sangam-toastr)[ Packagist](https://packagist.org/packages/sangamkatwal/sangam-toastr)[ Docs](https://github.com/143Sangam143/sangam-toastr)[ RSS](/packages/sangamkatwal-sangam-toastr/feed)WikiDiscussions main Synced today

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

🎉 Sangam Toastr
===============

[](#-sangam-toastr)

[![Latest Version](https://camo.githubusercontent.com/a687fdff3ed66d12fbc62bc8344b00d32bb5edec7f8c5d2a49b6b40e96f985a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616e67616d6b617477616c2f73616e67616d2d746f617374722e737667)](https://packagist.org/packages/sangamkatwal/sangam-toastr)[![License](https://camo.githubusercontent.com/f5fb0652404d9f4a2db52f413ac4a3ca858d3d08393e6068fa3abe2210ec6f0f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73616e67616d6b617477616c2f73616e67616d2d746f617374722e737667)](https://packagist.org/packages/sangamkatwal/sangam-toastr)

A simple and elegant Laravel package for **Toastr notifications** that works seamlessly with both **session flash messages** and **AJAX responses**.

> **Note**: This is my first Laravel package! 🚀 If anything isn't clear, feel free to reach out via email or create an issue.

✨ Features
----------

[](#-features)

- 🔄 **Dual Support**: Works with both session redirects and AJAX calls
- 🎨 **4 Notification Types**: Success, Error, Warning, Info
- 🚀 **Zero Configuration**: Works out of the box
- 📱 **Responsive**: Mobile-friendly notifications
- 🔧 **Laravel Integration**: Auto-discovery support
- 💡 **Simple API**: Consistent key-value pair format

📦 Installation
--------------

[](#-installation)

```
composer require sangamkatwal/sangam-toastr
```

🔧 Setup
-------

[](#-setup)

### 1. Publish Assets

[](#1-publish-assets)

```
# Publish everything
php artisan vendor:publish --tag=sangam-toastr

# Or publish separately
php artisan vendor:publish --tag=sangam-toastr-assets
php artisan vendor:publish --tag=sangam-toastr-views
```

### 2. Include Assets in Layout

[](#2-include-assets-in-layout)

Add to your `layouts/app.blade.php` (inside ``):

```
{{-- jQuery (required) --}}

{{-- Toastr Assets --}}

```

### 3. Include Notifications

[](#3-include-notifications)

Add before closing `` tag in your layout:

```
@include('sangam-toastr::toastr')
```

🚀 Usage
-------

[](#-usage)

### Session Flash Messages (Redirects)

[](#session-flash-messages-redirects)

```
// Success notification
return redirect()->back()->with([
    'success' => true,
    'message' => 'Data saved successfully!'
]);

// Error notification
return redirect()->back()->with([
    'error' => true,
    'message' => 'Something went wrong!'
]);

// Multiple messages (arrays supported)
return redirect()->back()->with([
    'error' => true,
    'message' => ['Field is required', 'Email must be valid']
]);
```

### AJAX Responses

[](#ajax-responses)

```
// Success response
return response()->json([
    'success' => true,
    'message' => 'Operation completed!'
]);

// Error response
return response()->json([
    'error' => true,
    'message' => 'Validation failed!'
]);
```

### Frontend AJAX Implementation

[](#frontend-ajax-implementation)

```
$.ajax({
    url: '/your-endpoint',
    type: 'POST',
    data: formData,
    success: function(response) {
        // This will automatically show toastr notifications
        ajax_response(response);

        // Alternative function name
        // showToastr(response);
    },
    error: function(xhr) {
        // Handle server errors
        ajax_response({
            error: true,
            message: 'Server error occurred'
        });
    }
});
```

### Mixed Request Types (AJAX + Regular)

[](#mixed-request-types-ajax--regular)

Perfect for controllers that handle both AJAX and regular requests:

```
public function store(Request $request)
{
    try {
        // Your logic here...

        $message = 'Record created successfully!';

        return $request->ajax()
            ? response()->json(['success' => true, 'message' => $message])
            : redirect()->back()->with(['success' => true, 'message' => $message]);

    } catch (Exception $e) {
        $message = 'Something went wrong!';

        return $request->ajax()
            ? response()->json(['error' => true, 'message' => $message])
            : redirect()->back()->with(['error' => true, 'message' => $message]);
    }
}
```

📋 Notification Types
--------------------

[](#-notification-types)

TypeUsage`success`✅ Success operations`error`❌ Error messages`warning`⚠️ Warning alerts`info`ℹ️ Information notices⚙️ Requirements
---------------

[](#️-requirements)

- **PHP**: &gt;= 8.0
- **Laravel**: 8.x, 9.x, 10.x, 11.x
- **jQuery**: 3.7.1 (recommended, not tested with other versions)

🔍 Validation Examples
---------------------

[](#-validation-examples)

See [ValidationExamples.md](docs/ValidationExamples.md) for detailed examples with Laravel validation.

🤝 Contributing
--------------

[](#-contributing)

This is my first package, so contributions and suggestions are very welcome!

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Submit a pull request

📝 License
---------

[](#-license)

This package is open-sourced under the [MIT license](LICENSE).

👨‍💻 Author
----------

[](#‍-author)

**Sangam Katwal** -

✍️ Note By Author
-----------------

[](#️-note-by-author)

This README was written with the help of AI based on my inputs. If you notice anything unclear or incorrect, feel free to reach out to me via email.

The Toastr CSS and JS used in this package are from the original Toastr.js v2.1.3. This package is completely free and open-source.

The main reason I built this package is because I often had to dig through old projects just to copy my custom Toastr response logic. By turning it into a reusable package, I’ve made it easier for myself—and I’m sharing it publicly in case it simplifies things for others too.

👨‍💻 Note For Developers
-----------------------

[](#‍-note-for-developers)

While this package encourages a simple and consistent response format (one notification type + one message), it does not restrict Laravel’s default flexibility. You can still attach additional values to your responses, whether for session flashes or AJAX.

For example:

```
// Redirect response with extra data
return redirect()->back()->with([
    'success' => true,
    'message' => 'Data saved successfully!',
    'status'  => 200,
    'extra'   => 'Any other value'
]);

// AJAX response with extra fields
return response()->json([
    'success' => true,
    'message' => 'Data saved successfully!',
    'status'  => 200,
    'data'    => ['id' => 123, 'name' => 'Sample']
]);

So, you still get all the power of Laravel responses while enjoying clean, consistent Toastr notifications. 🚀

---

⭐ **Star this repo if it helped you!**
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance56

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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 ~21 days

Total

2

Last Release

291d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/108720249?v=4)[Sangam Katwal](/maintainers/143Sangam143)[@143Sangam143](https://github.com/143Sangam143)

---

Top Contributors

[![143Sangam143](https://avatars.githubusercontent.com/u/108720249?v=4)](https://github.com/143Sangam143 "143Sangam143 (11 commits)")

---

Tags

laravelnotificationsajaxtoastrflash-messagessangam

### Embed Badge

![Health badge](/badges/sangamkatwal-sangam-toastr/health.svg)

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

###  Alternatives

[devrabiul/laravel-toaster-magic

Laravel Toaster Magic is a lightweight, flexible toast library for Laravel projects, with no jQuery, Bootstrap, or Tailwind dependency.

22671.4k1](/packages/devrabiul-laravel-toaster-magic)

PHPackages © 2026

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