PHPackages                             live-controls/alerts - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. live-controls/alerts

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

live-controls/alerts
====================

Sweet Alerts library for live-controls

v1.0.7(2y ago)024PHP

Since Aug 19Pushed 2y agoCompare

[ Source](https://github.com/live-controls/alerts)[ Packagist](https://packagist.org/packages/live-controls/alerts)[ RSS](/packages/live-controls-alerts/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (2)Versions (12)Used By (0)

Alerts
======

[](#alerts)

[![Release Version](https://camo.githubusercontent.com/7e93818fc9521b91927d91f1f65feb13a52f21273d656df10aba2ab473e97032/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6c6976652d636f6e74726f6c732f616c65727473)](https://camo.githubusercontent.com/7e93818fc9521b91927d91f1f65feb13a52f21273d656df10aba2ab473e97032/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6c6976652d636f6e74726f6c732f616c65727473)[![Packagist Version](https://camo.githubusercontent.com/03c7889bedb4a3a609bd7655ff02daaa0451d56fa097cfcb0285a821896bfa64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6976652d636f6e74726f6c732f616c657274733f636f6c6f723d253233303037353030)](https://camo.githubusercontent.com/03c7889bedb4a3a609bd7655ff02daaa0451d56fa097cfcb0285a821896bfa64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6976652d636f6e74726f6c732f616c657274733f636f6c6f723d253233303037353030)Alerts library for live-controls

Requirements
------------

[](#requirements)

- Laravel 9+
- Livewire 2+

Translations
------------

[](#translations)

- English (en)
- German (de)
- Brazilian Portuguese (pt\_BR)

Installation
------------

[](#installation)

1. Install Alerts package

```
composer require live-controls/alerts
```

2. Include @livewire('livecontrols-sweetalert') to layout before /body tag

Usage
-----

[](#usage)

First Step: Add HasPopups trait to Livewire Controls or classes that make use of redirect().

```
use HasPopups;
```

### New System

[](#new-system)

The new system has many benefits over the old one, you can not only set custom titles and buttons, but you can also call Livewire events if the user did press confirm, deny or cancel buttons. More options will mostlikely be added in the future.

Required Parameters: 'type' and 'message', the rest is optional

From Controller

```
$alertType = 'success'; //Can be success, warning, error, info and question
$alertTitle = 'Some Title'; //Will be shown as title
$alertMessage = 'This is some message'; //can contain HTML so be aware of that!
$alertConfirmButtonText = 'Confirm'; //The text shown on the confirm button, if you dont want to show the button set it to null or don't set it in the call
$alertDenyButtonText = 'Deny'; //Same as confirm button
$alertCancelButtonText = 'Cancel'; //Same as confirm button
$alertConfirmEvent = 'confirmed'; //The name of the event that will be called when the user clicks on the confirm button set to null or don't set it in the call to ignore it
$alertDenyEvent = 'denied'; //Same as confirm event
$alertCancelEvent = 'canceled'; //Same as confirm event

//New in 0.4-dev
$alertTimer = 2000; //Will close the window after 2000ms
$alertTimerProgressBar = true; //If set to true it will show a progressbar on the bottom
$alertImageUrl = 'https://yourpage.com/somepicture.jpg'; //Sets a picture for the alert
$alertImageHeight = 100; //Sets the height of the image
$alertImageWidth = 100; //Sets the width of the image
$alertImageAlt = 'Some Text'; //Sets an alternative text to the image
$alertHtml = 'I'm strong!'; //Sets the html of the message, ignores message if set! Take care with that and don't allow userinput on this one!

return redirect()->route('dashboard')->with('alert', [
'type' => $alertType,
'title' => $alertTitle,
'message' => $alertMessage,
'confirmButtonText' => $alertConfirmButtonText,
'denyButtonText' => $alertDenyButtonText,
'cancelButtonText' => $alertCancelButtonText,
'confirmEvent' => $alertConfirmEvent,
'denyEvent' => $alertDenyEvent,
'cancelEvent' => $alertCancelEvent,

'timer' => $alertTimer,
'timerProgressBar' => $alertTimerProgressBar,
'imageUrl' => $alertImageUrl,
'imageHeight' => $alertImageHeight,
'imageWidth' => $alertImageWidth,
'imageAlt' => $alertImageAlt,
'html' => $alertHtml
]');

//New in 0.5-dev
return redirect()->route('dashboard')->alert(['type' => 'success', 'message' => 'Hello World!']);
```

From Livewire

```
$this->dispatchBrowserEvent('alert', [
 'type' => 'error',
 'title' => 'Test Title',
 'message' => 'It\'s working!',
 'confirmButtonText' => 'Confirm',
 'denyButtonText' => 'Deny',
 'cancelButtonText' => 'Cancel',
 'confirmEvent' => 'confirmPopup',
 'denyEvent' => 'denyPopup',
 'cancelEvent' => 'cancelPopup',

//new in 0.4-dev
'timer' => 2000,
'timerProgressBar' => true,
'imageUrl' => 'https://yourpage.com/cat.jpg',
'imageHeight' => 200,
'imageWidth' => 200,
'imageAlt' => 'A cute cat!',
'html' => 'Im strong!'
]);

//New in 0.5-dev
$this->alert([
'type' => 'info',
'message' => 'Hello World!'
]);
```

### Old System

[](#old-system)

If you want to use the old system you can send a session variable like so:

From Controller

```
return redirect()->route('dashboard')->with('success', 'This had success!'); //Will show a success popup
return redirect()->route('dashboard')->with('exception'), 'This had an exception!'); //Will show an error popup
return redirect()->route('dashboard')->with('info', 'This is an information'); //Will show an info popup
return redirect()->route('dashboard')->with('warning', 'This is a warning'); //Will show a warning popup
```

From Livewire

```
$this->dispatchBrowserEvent('showAlert', ['success', 'This had success!']); //Will show a success popup
$this->dispatchBrowserEvent('showAlert', ['exception', 'This had an exception']); //Will show an error popup
$this->dispatchBrowserEvent('showAlert', ['info', 'This is an information']); //Will show an info popup
$this->dispatchBrowserEvent('showAlert', ['warning', 'This is a warning']); //Will show a warning popup
```

As you can see the old system is very limited, you can only add the message to it and thats it. If you work on a new project, use the new system instead!

### Manual Installation

[](#manual-installation)

If you prefer to install the SweetAlert2 scripts yourself, follow the instructions here: Installation: Installation of Themes:

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Total

8

Last Release

1046d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/60240491?v=4)[Roman Wanner](/maintainers/daredloco)[@daredloco](https://github.com/daredloco)

---

Top Contributors

[![daredloco](https://avatars.githubusercontent.com/u/60240491?v=4)](https://github.com/daredloco "daredloco (21 commits)")

### Embed Badge

![Health badge](/badges/live-controls-alerts/health.svg)

```
[![Health](https://phpackages.com/badges/live-controls-alerts/health.svg)](https://phpackages.com/packages/live-controls-alerts)
```

###  Alternatives

[symfony/object-mapper

Provides a way to map an object to another object

361.5M55](/packages/symfony-object-mapper)[johndwells/craft.minimee

A Craft CMS port of the popular Minimee add-on for ExpressionEngine.

664.5k](/packages/johndwells-craftminimee)[aeon-php/business-hours

Abstraction allowing to define and check against business hours

10146.1k](/packages/aeon-php-business-hours)

PHPackages © 2026

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