PHPackages                             newton-labs/alertify-bundle - 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. newton-labs/alertify-bundle

ActiveSymfony-bundle

newton-labs/alertify-bundle
===========================

Symfony AlertifyBundle

2.0.3(9y ago)0166MITCSS

Since Jul 20Pushed 8y ago2 watchersCompare

[ Source](https://github.com/Newton-Labs/AlertifyBundle)[ Packagist](https://packagist.org/packages/newton-labs/alertify-bundle)[ Docs](https://github.com/Troopers/TroopersAlertifyBundle)[ RSS](/packages/newton-labs-alertify-bundle/feed)WikiDiscussions master Synced 1mo ago

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

[![Troopers](https://cloud.githubusercontent.com/assets/618536/18787530/83cf424e-81a3-11e6-8f66-cde3ec5fa82a.png)](http://troopers.agency)

[![Gitter](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/Troopers/TroopersAlertifyBundle)[![License](https://camo.githubusercontent.com/ae1ca38ac91598d5b956364e0900dece7507cb5751fa80ecd0d6a59458052c1b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74726f6f706572732f616c6572746966792d62756e646c652e737667)](https://packagist.org/packages/troopers/alertify-bundle)[![Version](https://camo.githubusercontent.com/134e83deb77ea3800a4476d74b67c3646a078cafada4ba69e5946d9d678ee633/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74726f6f706572732f616c6572746966792d62756e646c652e737667)](https://packagist.org/packages/troopers/alertify-bundle)[![SensioLabsInsight](https://camo.githubusercontent.com/9d2f241efedf5a1d0ef965875d7b8d758531c9bffd8e5198289c8f541acd6464/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f34643734313333352d616437372d343330382d393131332d6231363438633462653634652f6d696e692e706e67)](https://insight.sensiolabs.com/projects/4d741335-ad77-4308-9113-b1648c4be64e)
==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#)

Alertify Bundle
===============

[](#alertify-bundle)

What is the point ?
-------------------

[](#what-is-the-point-)

This bundle allows you to easily harmonize alerts and others notifications. Declare in the config (or just use the default configuration) and dispatch alerts with the following libraries ([or your own](#use-my-own-alert-system)):

- [Toastr](https://github.com/CodeSeven/toastr)
- [TwitterBootstrap](http://twitter.github.com/bootstrap/javascript.html#modals)
- [Noty](http://needim.github.com/noty/)
- [Codrops notifications](http://tympanus.net/Development/NotificationStyles)
- [Notie.js](https://github.com/jaredreich/notie.js)

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

[](#installation)

First, require it thanks to composer:

```
composer.phar require troopers/alertify-bundle:dev-master

```

Add it in your AppKernel.php:

```
public function registerBundles() {
    $bundles = array(
        [...]
        new Troopers\AlertifyBundle\TroopersAlertifyBundle(),
        [...]

```

To include the library of your choice, you have these 2 methods :

### automatically with [https://github.com/Troopers/AsseticInjectorBundle](AsseticInjectorBundle) (*recommended*)

[](#automatically-with-httpsgithubcomtroopersasseticinjectorbundle-recommended)

Just add the name of the resource tag (e.g alertify-toastr) in your regular assetic's block.

For example, this code ...

```
    {% javascripts injector="alertify-toastr"
        '@MyAcmeDemoBundle/Resources/public/js/loremipsumdolorsitamet.js'
     %}

    {% endjavascripts %}
```

and the same way for stylesheets (if needded) and for each one of availables librairies (`alertify-notie`, `alertify-codrops-notification`...).

### manually

[](#manually)

If you want to do this manually, you'll have to read the Resources/config/assetic\_injector.json file and add them manually :

```
    {% javascripts
        '@TroopersAlertifyBundle/Resources/public/toastr/js/toastr.js'
     %}

    {% endjavascripts %}
```

and the same way for stylesheets.

Configuration ?
---------------

[](#configuration-)

To define the default configuration of your alerts, you can add the following lines in your config.yml :

```
troopers_alertify:
    contexts:
        front:
            engine: "toastr"              \#Could be noty, modal, toastr or your own
            layout: "top-right"           \#Is relative according to the selected engine
            translationDomain: "messages" \#Where do you want to store the translation strings
        admin:
            engine: "myOwnSystem"
            layout: "bottomRight"
            translationDomain: "messages"
            options:
                background: rgb(99, 176, 205)
                anyOptionName: anyValue
```

By default, even if you do not declare any context, Alertify setup default values. You can override these settings easily like this:

```
troopers_alertify:
   default:
       context: app                \#default: front
       engine: noty                \#default: toastr
       layout: bottomLeft          \#default: top-right
       translationDomain: messages \#default: flash
   contexts:
   ...
```

How to ?
--------

[](#how-to-)

It's easy to use, just follow the following:

Add this block at the end of your twig layout:

```
 {% block alertify %}
    {{ app.session|alertify|raw }}
 {% endblock %}

```

Now, anywhere, you can put your alert in the flash session and enjoy.

```
$this->get('session')->getFlashBag()->add('success', 'ok');
$this->get('session')->getFlashBag()->add('warning', array('body' => 'ok');
$this->get('session')->getFlashBag()->add('warning', array('body' => 'ok', 'context' => 'front');

```

You can use the `troopers_alertifybundle.helper.alertifyhelper` service to ease the alert creation :

```
$this->container->get('troopers_alertifybundle.helper.alertifyhelper')->congrat('TEST');
$this->container->get('troopers_alertifybundle.helper.alertifyhelper')->warn('TEST');
$this->container->get('troopers_alertifybundle.helper.alertifyhelper')->inform('TEST');
$this->container->get('troopers_alertifybundle.helper.alertifyhelper')->scold('TEST');

```

You can also use the AlertifyControllerTrait to have simple methods in controller :

```
use Troopers\AlertifyBundle\Controller\AlertifyControllerTrait;

class MyController extends ...
{
    use AlertifyControllerTrait;

    /* You can use then all methods :
     * $this->alert("hello", $type = 'success');
     * $this->congrat("Congratulation");
     * $this->warn("Warning !");
     * $this->inform("Did you know ?");
     * $this->scold("What's wrong with you !");
     */
}
```

If you have two contexts in your application (front and back for example), I spur you to override these functions in your controller in each side to pass automatic context like this :

```
    class BaseFrontController
    {
        /**
         * congrat user through flashbag : all happened successfully
         * Will automatically inject context
         * @param string $content
         */
        public function congrat($content)
        {
            $content = array('body' => $content, 'context' => 'front');
            $this->get('av.shortcuts')->congrat($content);
        }
    }
```

Display alerts with a custom library
---------------------------------------------------------------------------------------

[](#display-alerts-with-a-custom-library)

TroopersAlertify comes with some librairies to ease use but it's free to you to use custom Library (feel free to make a Pull request, your library could interest community :). You just have to follow these steps :

```
troopers_alertify:
    contexts:
        front:
            engine: "myOwnSystem"
            layout: "bottomRight" \#it's up to your library
            translationDomain: "messages"
```

Then just override app/Resources/TroopersAlertifyBundle/views/Modal/**myOwnSystem**.html.twig and add the alert initialization.

Options
-------

[](#options)

### Modal

[](#modal)

To call a modal box, just use a flash named 'modal':

```
$this->get('session')->getFlashBag()->set("success", array('engine' => 'modal', 'title' => "Wow", 'button_class' => "btn btn-primary btn-large", "body"=> "Some info"));

```

as you see, you can pass some arguments tu customize the modal, availables ones are:

```
title:
  (html) string
button-class:
  you con specify classes to customize your button
body:
  html string
hasHeader:
  boolean (default = true)
hasFooter:
  boolean (default = true)
deleteIcon:
  string : icon-class (for example: "fa fa-times")
id:
  string : (default: "alertify-modal")

```

Callback type
-------------

[](#callback-type)

There is a final type of Alert you can call, the callback Callbach allow you to call any action in you project, thats awesome if you want put dynamic content in your alery. To work, the called action have to render a view. It's very usefull to include a form in a modal for exemple.

```
$this->get('session')
  ->getFlashBag()
  ->set('callback', array(
      'engine' => 'modal',
      'title' => 'Wow',
      'action' => 'AcmeBundle:Default:hello',
      'button_class' => 'btn btn-primary btn-large',
      'body' => 'Yeah that's crazy !'
    )
);

```

This type is very simple to use, just call the callback alery, and in the options define "type" with the final alert you want, the action with the action you want call, and other options specific to the alery you choose.

Ajax mode
---------

[](#ajax-mode)

We told you to add the alertify filter in your layout. This is great but what if you want to use ajax in your application ?

Actually, this library is not really made for it but you can simply add this part of code to trigger alerts in your new ajax content :

```
{% if app.request.isXmlHttpRequest %}
    {{ app.session|alertify|raw }}
{% endif %}

```

Confirm modal
-------------

[](#confirm-modal)

After a link's clic or form's submission, we sometimes want to prompt the user to be sure he understood what he did. You can make it as a simply way by following the doc here : ([https://github.com/Troopers/TroopersAlertifyBundle/blob/master/README\_Confirm.md](https://github.com/Troopers/TroopersAlertifyBundle/blob/master/README_Confirm.md))

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity69

Established project with proven stability

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

Recently: every ~2 days

Total

10

Last Release

3496d ago

Major Versions

1.0.0 → 2.0.02016-10-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/c9c566abf55765f697f68e4172ec59a263584691d682c01163571b2e18d116f6?d=identicon)[fcpauldiaz](/maintainers/fcpauldiaz)

---

Top Contributors

[![paulandrieux](https://avatars.githubusercontent.com/u/1942078?v=4)](https://github.com/paulandrieux "paulandrieux (22 commits)")[![lenybernard](https://avatars.githubusercontent.com/u/618536?v=4)](https://github.com/lenybernard "lenybernard (12 commits)")[![fcpauldiaz](https://avatars.githubusercontent.com/u/4523284?v=4)](https://github.com/fcpauldiaz "fcpauldiaz (3 commits)")[![BFoucher](https://avatars.githubusercontent.com/u/16239924?v=4)](https://github.com/BFoucher "BFoucher (2 commits)")[![Charlie-Lucas](https://avatars.githubusercontent.com/u/6369470?v=4)](https://github.com/Charlie-Lucas "Charlie-Lucas (2 commits)")[![juliensnz](https://avatars.githubusercontent.com/u/1117272?v=4)](https://github.com/juliensnz "juliensnz (2 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")[![thomasbeaujean](https://avatars.githubusercontent.com/u/5817919?v=4)](https://github.com/thomasbeaujean "thomasbeaujean (1 commits)")[![vincent-chapron](https://avatars.githubusercontent.com/u/10434344?v=4)](https://github.com/vincent-chapron "vincent-chapron (1 commits)")

---

Tags

bootstrapalert

### Embed Badge

![Health badge](/badges/newton-labs-alertify-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/newton-labs-alertify-bundle/health.svg)](https://phpackages.com/packages/newton-labs-alertify-bundle)
```

###  Alternatives

[kartik-v/yii2-dialog

An asset bundle for bootstrap3-dialog for Yii 2.0 framework.

496.2M18](/packages/kartik-v-yii2-dialog)[kartik-v/yii2-widget-growl

A widget to generate growl based notifications using bootstrap-growl plugin (sub repo split from yii2-widgets)

384.2M14](/packages/kartik-v-yii2-widget-growl)[kartik-v/yii2-widget-alert

A widget to generate alert based notifications using bootstrap-alert plugin (sub repo split from yii2-widgets)

284.1M24](/packages/kartik-v-yii2-widget-alert)[troopers/alertify-bundle

Symfony AlertifyBundle

4835.8k3](/packages/troopers-alertify-bundle)

PHPackages © 2026

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