Noty adapter for PHP flasher

Last updated at 08 May 2022 | Published at 28 November 2020

If you like PHPFlasher please consider giving it a on github or by spreading the word on twitter. Your support allows me to keep this package up-to-date and maintainable. Thank you


Installation

For more information about noty click here.

For Vanilla PHP:

composer require php-flasher/flasher-noty

For Laravel:

composer require php-flasher/flasher-noty-laravel

For Symfony:

composer require php-flasher/flasher-noty-symfony

Usage

Just instantiate the NotyFactory and start calling build methods

namespace App\Controller;

use Flasher\Noty\Prime\NotyFactory;

class NotifyController
{
    public function flasher(NotyFactory $flasher)
    {
        // ... 
        $flasher->addSuccess('Data has been saved successfully!');
        
        // ... redirect or render a view here
    }
}    

Fluent Builder methods

All methods in the Usage section are available also for NotyFactory


text

This string can contain HTML too. But be careful and don’t pass user inputs to this parameter.

$flasher->text(string $text)

alert

display alert type notification

$flasher->alert(string $message = null, array $options = array())

layout

top, topLeft, topCenter, topRight, center, centerLeft, centerRight, bottom, bottomLeft, bottomCenter, bottomRight - ClassName generator uses this value → noty_layout__${layout}

$flasher->layout(string $layout)

theme

relax, mint, metroui - ClassName generator uses this value → noty_theme__${theme}

$flasher->theme(string $theme)

timeout

false, 1000, 3000, 3500, etc. Delay for closing event in milliseconds (ms). Set ‘false’ for sticky notifications.

$flasher->timeout(int|bool $timeout)

progressBar

true, false - Displays a progress bar if timeout is not false.

$flasher->progressBar(bool $progressBar = false)

closeWith

click, button

$flasher->closeWith(string|array $closeWith)

animation

If string, assumed to be CSS class name. If null, no animation at all. If function, runs the function. (v3.0.1+) You can use animate.css class names or your custom css animations as well.

$flasher->animation(string $animation, string $effect)

sounds

$flasher->sounds(string $option, mixed $value)

docTitle

$flasher->docTitle(string $option, mixed $docTitle)

modal

$flasher->modal(bool $modal = true)

id

You can use this id with querySelectors. Generated automatically if false.

$flasher->id(bool|string $id)

force

DOM insert method depends on this parameter. If false uses append, if true uses prepend.

$flasher->force(bool $force = true)

queue

$flasher->queue(string $queue)

killer

If true closes all visible notifications and shows itself. If string(queueName) closes all visible notification on this queue and shows itself.

$flasher->killer(bool|string $killer)

container

Custom container selector string. Like ‘.my-custom-container’. Layout parameter will be ignored.

$flasher->container(bool|string $container)

buttons

An array of Noty.button, for creating confirmation dialogs.

$flasher->buttons(array $buttons)

visibilityControl

If true Noty uses PageVisibility API to handle timeout. To ensure that users do not miss their notifications.

$flasher->visibilityControl(bool $visibilityControl)
Younes

PHPFlasher is a project by Younes KHOUBZA.