2017 © Pedro Peláez
 

library notify

Flexible flash notifications for Yii2

image

suxiaolin/notify

Flexible flash notifications for Yii2

  • Wednesday, November 25, 2015
  • by suxiaolin
  • Repository
  • 1 Watchers
  • 4 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Notify, (*1)

Build Status Code Climate Issue Count Latest Stable Version Latest Unstable Version Total Downloads License, (*2)

Install

Using Composer, (*3)

composer require suxiaolin/notify

Add the components to config/main.php, (*4)

'notifier' => [
    'class' => 'suxiaolin\notify\Notifier',
]

Note, there is a Notifier::instance() function available, so you can via Notifier::instance() instead of config it in config/main.php., (*5)

Usage

Basic

From your application, call the flash method with a message and type., (*6)

Notifier::instance()->flash('Welcome back!', 'success');

Within a view, you can now check if a flash message exists and output it., (*7)

<?php if (Notifier::instance()->ready()): ?>
    <div class="alert-box <?= Notifier::instance()->type() ?>">
        <?= Notifier::instance()->message() ?>
    </div>
<?php endif; ?>

Notify is front-end framework agnostic, so you're free to easily implement the output however you choose., (*8)

Options

You can pass additional options to the flash method, which are then easily accessible within your view., (*9)

Notifier::instance()->flash('Welcome back!', 'success', [
    'timer' => 3000,
    'text' => 'It\'s really great to see you again',
]);

Then, in your view., (*10)

<?php if (Notifier::instance()->ready()): ?>
    <script>
        swal({
            title: "<?= Notifier::instance()->message() ?>",
            text: "<?= Notifier::instance()->option('text') ?>",
            type: "<?= Notifier::instance()->type() ?>",
            <?php if (Notifier::instance()->option('timer')): ?>
                timer: <?= Notifier::instance()->option('timer') ?>,
                showConfirmButton: false
            <?php endif; ?>
        });
    </script>
<?php endif; ?>

SweetAlert example, (*11)

The above example uses SweetAlert, but the flexibily of Notify means you can easily use it with any JavaScript alert solution., (*12)

Issues and contribution

Just submit an issue or pull request through GitHub. Thanks!, (*13)

The Versions

25/11 2015

dev-master

9999999-dev

Flexible flash notifications for Yii2

  Sources   Download

MIT

The Requires

 

The Development Requires

by 苏小林

22/11 2015

1.0.1

1.0.1.0

Flexible flash notifications for Yii2

  Sources   Download

MIT

The Requires

 

by 苏小林

22/11 2015

1.0.0

1.0.0.0

Flexible flash notifications for Yii2

  Sources   Download

MIT

The Requires

 

by 苏小林