PHPackages                             softon/sweetalert - 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. softon/sweetalert

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

softon/sweetalert
=================

Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.

v1.0.2(6y ago)2936.1k↓50%11[1 PRs](https://github.com/softon/sweetalert/pulls)1MITPHPPHP &gt;=5.4.0

Since Dec 3Pushed 5y ago3 watchersCompare

[ Source](https://github.com/softon/sweetalert)[ Packagist](https://packagist.org/packages/softon/sweetalert)[ RSS](/packages/softon-sweetalert/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (1)

SweetAlert 2
------------

[](#sweetalert-2)

Laravel 5 Package for [SweetAlert 2](https://github.com/sweetalert2/sweetalert2/). Use this package to easily show SweetAlert prompts in your Laravel application.

### Installation

[](#installation)

1. Use composer to install the package

```
$ composer require softon/sweetalert
```

2. (Optional for Laravel 5.5) Add the service provider to the config/app.php file in Laravel

```
Softon\SweetAlert\SweetAlertServiceProvider::class,
```

3. (Optional for Laravel 5.5) Add an alias for the Facade to the config/app.php file in Laravel

```
'SWAL' => Softon\SweetAlert\Facades\SWAL::class,
```

4. Publish the config &amp; views by running

```
$ php artisan vendor:publish
```

### View

[](#view)

This package does have its own views to be included in your templates. But if you would like to tweak it or include your own you can use the views published in the `resources/views/vendor/sweetalert` directory.

This package also includes a SweetAlert2 CDN that you can include if you have not included the SweetAlert2 Javascript file from their website. The CDN view must be loaded first.

For built in views, you can use this in your blade templates before the closing body tag

```
@include('sweetalert::cdn')         // Optional needed only if SweetAlert2 files are not inserted by the developer
@include('sweetalert::view')
@include('sweetalert::validator')   // Optional needed only to show form validation errors automatically
```

Or for the Published Views use this

```
@include('vendor.sweetalert.cdn')   // Optional needed only if SweetAlert2 files are not inserted by the developer
@include('vendor.sweetalert.view')
@include('vendor.sweetalert.validator')   // Optional needed only to show form validation errors automatically
```

### Configuration

[](#configuration)

You can change the basic parameters of the package by referring to the [SweetAlert2](https://github.com/sweetalert2/sweetalert2/) documentations for more details.

### Usage

[](#usage)

You may use the SWAL Facade or the swal helper function to call the methods.

Showing a Message to User using the SWAL Facade:

```
use Softon\SweetAlert\Facades\SWAL;

// Params: [Title,Text,Type,Options[]]
SWAL::message('Good Job','You have successfully logged In!','info');
SWAL::message('Good Job','You have successfully logged In!','error');
SWAL::message('Good Job','You have successfully logged In!','success',['timer'=>2000]);

// For All available options please refer the SweetAlert 2 Docs
```

Showing a Message to User using the swal helper function:

```
// Message Type Can be `warning`, `error`, `success`, `info` and `question`. Based on this there are some convinence function that can be used instead of the message method.:
swal('Your Title','Text');
swal()->message('Good Job','You have successfully logged In!','info');
swal()->message('Good Job','You have successfully logged In!','error');
swal()->message('Good Job','You have successfully logged In!','success',['timer'=>2000]);
```

```
// Params [Title, Text, Options]
swal()->warning('Good Job','You have successfully logged In!',[]);
swal()->error('Good Job','You have successfully logged In!',[]);
swal()->success('Good Job','You have successfully logged In!',[]);
swal()->info('Good Job','You have successfully logged In!',[]);
swal()->question('Good Job','You have successfully logged In!',[]);
```

To show modal which will autoclose after few seconds:

```
swal()->autoclose(2000)->message('Good Job','You have successfully logged In!','info');
swal()->autoclose(5000)->success('Good Job','You have successfully logged In!');
```

To show a toast modal which will autoclose after few seconds:

```
swal()->toast()->autoclose(2000)->message('Good Job','You have successfully logged In!','info');
```

To change confirm button text:

```
swal()->button('Close Me')->message('Good Job','You have successfully logged In!','info');

// Button Params [Button Text,Button Colour, SWAL Style Enable / Disable, Style Class for Buttons]
swal()->button('Close Me','#efefef',false,'btn btn-primary')->info('Good Job','You have successfully logged In!');
```

To change position of the modal:

```
// Possible Positions : `top`, `top-left`, `top-right`, `center`, `center-left`, `center-right`, `bottom`, `bottom-left`, or `bottom-right`
swal()->position('top')->message('Good Job','You have successfully logged In!','info');
```

You can chain any of these methods to combine the functionality:

```
swal()->position('bottom-right')->autoclose(3000)->toast()->message('This is A Custom Message');
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

2

Last Release

2223d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b1203b3f0be622a928325d7138799bd0b50f4f7f5b09c608630c9961b3b0625?d=identicon)[softon](/maintainers/softon)

---

Top Contributors

[![softon](https://avatars.githubusercontent.com/u/598761?v=4)](https://github.com/softon "softon (4 commits)")[![nasrulhazim](https://avatars.githubusercontent.com/u/10341422?v=4)](https://github.com/nasrulhazim "nasrulhazim (3 commits)")[![lopuk](https://avatars.githubusercontent.com/u/1978906?v=4)](https://github.com/lopuk "lopuk (1 commits)")[![zymawy](https://avatars.githubusercontent.com/u/15253683?v=4)](https://github.com/zymawy "zymawy (1 commits)")

---

Tags

laravel-5-packagelaravel-packagelaravel55sweetalert2laravel 5sweetalert2POPUP BOXES

### Embed Badge

![Health badge](/badges/softon-sweetalert/health.svg)

```
[![Health](https://phpackages.com/badges/softon-sweetalert/health.svg)](https://phpackages.com/packages/softon-sweetalert)
```

###  Alternatives

[nativephp/mobile

NativePHP for Mobile

82724.0k43](/packages/nativephp-mobile)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[adrianorosa/laravel-geolocation

Laravel Geo Location package to get details for a given IP Address

6593.3k1](/packages/adrianorosa-laravel-geolocation)

PHPackages © 2026

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