PHPackages                             kv4nt/yii2-sweet-alert - 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. [Templating &amp; Views](/categories/templating)
4. /
5. kv4nt/yii2-sweet-alert

ActiveYii2-extension[Templating &amp; Views](/categories/templating)

kv4nt/yii2-sweet-alert
======================

A Yii2 widget for SweetAlert

v1.0.1(8y ago)04.4kMITPHP

Since Sep 13Pushed 8y ago1 watchersCompare

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

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

SweetAlert Widget for Yii 2
===========================

[](#sweetalert-widget-for-yii-2)

SweetAlert widget based on [SweetAlert](http://lipis.github.io/bootstrap-sweetalert/)

[![Latest Stable Version](https://camo.githubusercontent.com/ab2f5fc3919ef0de5e722fcf5d9e57bb2e7c6b3224784e49c468aa205a49ed15/68747470733a2f2f706f7365722e707567782e6f72672f6b76346e742f796969322d73776565742d616c6572742f762f737461626c652e737667)](https://packagist.org/packages/kv4nt/yii2-sweet-alert)[![Total Downloads](https://camo.githubusercontent.com/1dae0da648aba0ca1d1ddd616774327e6178e8460415b10a807cffeb491b6116/68747470733a2f2f706f7365722e707567782e6f72672f6b76346e742f796969322d73776565742d616c6572742f646f776e6c6f6164732e737667)](https://packagist.org/packages/kv4nt/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 kv4nt/yii2-sweet-alert "*"

```

or add

```
"kv4nt/yii2-sweet-alert": "*"
```

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 \kv4nt\sweetalert\SweetAlert::widget();
```

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

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

echo \kv4nt\sweetalert\SweetAlert::widget([
    'useSessionFlash' => false,
    'options' => [
        'timer' => null,
        'type' => \kv4nt\sweetalert\SweetAlert::TYPE_INPUT,
        'title' => 'An input!',
        'text' => "Write something interesting",
        'confirmButtonText' => "Yes, delete it!",
        'closeOnConfirm' => false,
        'showCancelButton' => true,
        'animation' => "slide-from-top",
        'inputPlaceholder' => "Write something"
    ],
    'callback' => new \yii\web\JsExpression(' function(inputValue) {
                if (inputValue === false) return false;
                if (inputValue === "") {
                    swal.showInputError("You need to write something!");
                    return false;
                }
                swal("Good!", "You wrote: " + inputValue, "success");
    }')
]);
```

Alert Options
-------------

[](#alert-options)

You can find them on the [options page](https://sweetalert.js.org/docs/)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

2

Last Release

3161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d15ae5e94c57df8fb20e66d0d860cc741c2a6f6b2c2fb9d5dd323bb7f9a529c?d=identicon)[kv4nt](/maintainers/kv4nt)

---

Top Contributors

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

---

Tags

yii2sweet-alertsweetalertyii2 alert yi2i sweet alert

### Embed Badge

![Health badge](/badges/kv4nt-yii2-sweet-alert/health.svg)

```
[![Health](https://phpackages.com/badges/kv4nt-yii2-sweet-alert/health.svg)](https://phpackages.com/packages/kv4nt-yii2-sweet-alert)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[yiister/yii2-adminlte

yii2-adminlte is a package for yii framework 2 that consists a very popular backend template AdminLTE (based on bootstrap 3).

2839.3k](/packages/yiister-yii2-adminlte)[marekpetras/yii2-calendarview-widget

CalendarView widget for Yii 2 Framework.

2229.1k](/packages/marekpetras-yii2-calendarview-widget)[nkovacs/yii2-datetimepicker

Bootstrap datetimepicker widget for Yii 2, based on Eonasdan/bootstrap-datetimepicker.

1062.7k](/packages/nkovacs-yii2-datetimepicker)[ricar2ce/yii2-material-theme

Material Theme for Yii2

175.8k](/packages/ricar2ce-yii2-material-theme)

PHPackages © 2026

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