Download the PHP package haxneeraj/laravel-livewire4-toaster without Composer

On this page you can find all versions of the php package haxneeraj/laravel-livewire4-toaster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-livewire4-toaster

๐Ÿž Livewire4 Toaster

Latest Version on Packagist PHP Version

Elegant toast notifications for Laravel Livewire 4 + Alpine.js โ€” event-driven, configurable, zero external dependencies.

Toast Preview Toast Preview Toast Preview Toast Preview

๐Ÿ“ธ Demo


โœจ Features


๐Ÿ“ฆ Installation

1. Install via Composer

The package auto-discovers its service provider and facade.

2. Publish Config (Optional)

This creates config/toaster.php where you can customize everything.

3. Add the Toast Hub to Your Layout

Place the toast-hub component in your main layout file, typically before </body>:

That's it! You're ready to toast. ๐Ÿž


๐Ÿš€ Usage

In Livewire Components (Toastable Trait)

The Toastable trait is the primary API for Livewire components:

In Controllers (Toast Facade)

Use the Toast facade for controller-based workflows:

Note: When using the facade with redirects, register the InjectToasts middleware (see Middleware Setup).

Global Helper Function

From JavaScript

Include resources/js/toast.js in your build, or use the global window.Toast object (available when the hub is loaded):

Or dispatch a raw event:

In Alpine.js


โš™๏ธ Configuration

Publish the config file:

Configuration Reference

Key Type Default Description
position string "top-right" Toast position. Options: top-right, top-left, bottom-right, bottom-left, top-center, bottom-center
duration int 3000 Auto-dismiss time in ms. 0 = sticky (manual dismiss only)
closable bool true Show close (ร—) button
close_on_click bool true Click anywhere on toast to dismiss
pause_on_hover bool true Pause auto-dismiss when hovering
max_toasts int 5 Max visible toasts. 0 = unlimited
queue bool false Queue mode: show one at a time
suppress_duplicates bool false Ignore duplicate type+message
replace_duplicates bool false Replace existing duplicate
show_icon bool true Show type-specific icon
show_progress_bar bool true Show animated progress bar
event_name string "toast" Browser event name
styles array see below Per-type Tailwind CSS classes

Style Configuration

Each toast type has customizable Tailwind classes:


๐Ÿ”ง Middleware Setup

To use the Toast facade or toast() helper in controllers (especially with redirects), register the InjectToasts middleware.

Laravel 11+ (bootstrap/app.php)

Laravel 10 (app/Http/Kernel.php)

The middleware:

  1. Collects pending toasts from ToastManager and session flash
  2. Injects a <script> tag before </body> that dispatches window events
  3. The Alpine toast-hub catches these events and renders the toasts

๐ŸŽจ Customizing Views

Publish the views to fully customize the toast markup:

This copies the Blade component to resources/views/vendor/livewire-toaster/.

Tailwind CSS Purge

Add the package views to your Tailwind content paths:


๐Ÿงช Testing

Running Tests

Testing Your Toasts

When testing Livewire components that use the Toastable trait:

When testing controllers that use the facade:


๐Ÿ“– API Reference

Toastable Trait Methods

Method Signature Description
success() success(string $message, ?string $title = null, array $options = []) Green success toast
error() error(string $message, ?string $title = null, array $options = []) Red error toast
info() info(string $message, ?string $title = null, array $options = []) Blue info toast
warning() warning(string $message, ?string $title = null, array $options = []) Amber warning toast
toast() toast(string $type, string $message, ?string $title = null, array $options = []) Generic toast

Toast Facade / Manager Methods

Same methods as above, plus:

Method Description
toArray() Get all pending toasts
flush() Get and clear pending toasts
flashToSession() Flash toasts to session (for redirects)
hasPending() Check if toasts are queued
count() Count pending toasts

Per-Toast Options

Pass as the $options array:


๐Ÿ“ Package Structure


๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing)
  5. Open a Pull Request

Please ensure tests pass (vendor/bin/phpunit) and follow PSR-12 coding standards.


๐Ÿ“ License

The MIT License (MIT). See LICENSE for details.


๐Ÿ™ Credits


All versions of laravel-livewire4-toaster with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/contracts Version ^10.0|^11.0|^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package haxneeraj/laravel-livewire4-toaster contains the following files

Loading the files please wait ...