PHPackages                             danvick/yii2-sweetalert2 - 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. danvick/yii2-sweetalert2

ActiveYii2-extension

danvick/yii2-sweetalert2
========================

Alert widget based on SweetAlert2 extension {@link https://sweetalert2.github.io/)

0320PHP

Since Mar 9Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

Yii2 Sweet Alert2 Widget
========================

[](#yii2-sweet-alert2-widget)

Alert widget based on [SweetAlert2](https://sweetalert2.github.io/)

[![Latest Stable Version](https://camo.githubusercontent.com/09a67360f50861dc9776086fffc93da86289dc496ec4abe9717f28dbaa949616/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d73776565742d616c6572742f762f737461626c65)](https://packagist.org/packages/yii2mod/yii2-sweet-alert) [![Total Downloads](https://camo.githubusercontent.com/d3fddfdd28615e123e08b55092dbaca7099caae5b66837294b789cc519fcc221/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d73776565742d616c6572742f646f776e6c6f616473)](https://packagist.org/packages/yii2mod/yii2-sweet-alert) [![License](https://camo.githubusercontent.com/0407a731f90b042063372ab16f1def190183ecfcca41d3312c0896fe9b2c457e/68747470733a2f2f706f7365722e707567782e6f72672f796969326d6f642f796969322d73776565742d616c6572742f6c6963656e7365)](https://packagist.org/packages/yii2mod/yii2-sweet-alert)[![Build Status](https://camo.githubusercontent.com/a2c879c419a5b1d9ee5f1d107be2ee7cf566156d79e9a01bcd1efafebb106fa9/68747470733a2f2f7472617669732d63692e6f72672f796969326d6f642f796969322d73776565742d616c6572742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yii2mod/yii2-sweet-alert)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist danvick/yii2-sweetalert2 "*"

```

or add

```
"danvick/yii2-sweetalert2": "*"

```

to the require section of your composer.json.

Usage
-----

[](#usage)

**For render the message from session flash you can use the following code:**

1. Set the message in your action, for example:

```
Yii::$app->session->setFlash('success', 'This is the message');
```

2. Simply add widget to your page as follows:

```
echo danvick\sweetalert2\SweetAlert::widget();
```

**For render the custom message you can use the following code:**

```
// A replacement for the "prompt" function

echo \danvick\yii2-sweetalert2\SweetAlert::widget([
        'type' => \danvick\yii2-sweetalert2\SweetAlert::TYPE_WARNING,
        'options' => [
            'title' => 'Oops...',
            'text' => 'Something went wrong!',
            'footer' => 'Why do I have this issue?'
        ]
]);
```

\*\* Javascrip Confrim Dialog Override\*\*

The native javascript confirm dialog is overridden by default, to disable this override, use the following configuration in config.php or web,php(in advanced template):

```
'assetManager' => [
    'bundles' => [
        'danvick\yii2-sweetalert2\SweetAlertAsset' => [
            'overrideConfirm' => false
        ]
    ]
]
```

Sweet Alert2 Options
--------------------

[](#sweet-alert2-options)

You can find them on the [sweetalert2 homepage](https://sweetalert2.github.io/)

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 81.3% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/90f313a3918693b91da6bad0ec9a5877f6f8188ae04f0bdbcb58602e08320cee?d=identicon)[danvick](/maintainers/danvick)

---

Top Contributors

[![kamran377](https://avatars.githubusercontent.com/u/7840072?v=4)](https://github.com/kamran377 "kamran377 (13 commits)")[![danvick](https://avatars.githubusercontent.com/u/7383575?v=4)](https://github.com/danvick "danvick (3 commits)")

### Embed Badge

![Health badge](/badges/danvick-yii2-sweetalert2/health.svg)

```
[![Health](https://phpackages.com/badges/danvick-yii2-sweetalert2/health.svg)](https://phpackages.com/packages/danvick-yii2-sweetalert2)
```

PHPackages © 2026

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