If you find PHPFlasher useful, we would greatly appreciate your support in the form of a star rating ⭐ on GitHub or by sharing the project on Twitter click here. Your feedback helps us keep the package up-to-date and well-maintained. Thank you


Installation

Laravel:

composer require php-flasher/flasher-noty-laravel


Symfony:

composer require php-flasher/flasher-noty-symfony

Usage

#/ noty

namespace App\Controller;

class AppController
{
    public function save()
    {        
        noty()->addSuccess('Your account has been un-terminated.');
    }
}

Modifiers

For more information on Noty options and usage, please refer to the original documentation at https://ned.im/noty/


The methods described in the Usage section can also be used with the noty adapter.


layout

top, topLeft, topCenter, topRight, center, centerLeft, centerRight, bottom, bottomLeft, bottomCenter, bottomRight

ClassName generator uses this value → noty_layout__${layout}

noty()->layout(string $layout);
#/ noty layout

noty()
    ->layout('topCenter')
    ->addInfo('Your request has been received and is being processed.');

theme

Possible values: relax, mint, metroui, light, sunset, nest.

ClassName generator uses this value → noty_theme__${theme}

noty()->theme(string $theme);

Default Theme: mint


Examples:

#/ noty theme mint

noty()
    ->theme('mint')
    ->addSuccess('Your account has been reactivated.');

noty()
    ->theme('mint')
    ->addError('Oops, something went wrong.');

noty()
    ->theme('mint')
    ->addWarning('Your review may not have been submitted.');

noty()
    ->theme('mint')
    ->addInfo('Your account has been deactivated and a confirmation email has been sent.');
#/ noty theme relax

// don't the load the theme css file: https://github.com/needim/noty/blob/master/lib/themes/relax.css

noty()
    ->theme('relax')
    ->addSuccess('The process was completed successfully.');

noty()
    ->theme('relax')
    ->addError('There was an issue re-activating your account.');

noty()
    ->theme('relax')
    ->addWarning('Caution: May have unintended consequences.');

noty()
    ->theme('relax')
    ->addInfo('Your report has been generated and a confirmation email has been sent.');
#/ noty theme metroui

// Theme: https://github.com/needim/noty/blob/master/lib/themes/metroui.css

noty()
    ->theme('metroui')
    ->addSuccess('Your account has been reactivated.');

noty()
    ->theme('metroui')
    ->addError('There was an issue submitting your feedback.');

noty()
    ->theme('metroui')
    ->addWarning('Your item may not have been added to the cart.');

noty()
    ->theme('metroui')
    ->addInfo('Your account has been terminated and a confirmation email has been sent.');
#/ noty theme light

// Theme: https://github.com/needim/noty/blob/master/lib/themes/light.css

noty()
    ->theme('light')
    ->addSuccess('The operation was successful.');

noty()
    ->theme('light')
    ->addError('There was an issue restoring your account.');

noty()
    ->theme('light')
    ->addWarning('Your password may not have been set.');

noty()
    ->theme('light')
    ->addInfo('Your password has been changed and a confirmation email has been sent.');
#/ noty theme sunset
// Theme: https://github.com/needim/noty/blob/master/lib/themes/sunset.css

noty()
    ->theme('sunset')
    ->addSuccess('Your account has been restored.');

noty()
    ->theme('sunset')
    ->addError('There was an issue saving your information.');

noty()
    ->theme('sunset')
    ->addWarning('Your account may not have been reinstated.');

noty()
    ->theme('sunset')
    ->addInfo('Your contact has been added and a confirmation email has been sent.');

timeout

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

noty()->timeout(int|bool $timeout)
#/ noty timeout

noty()
    ->timeout(2000) // 2 seconds
    ->addError('There was a problem re-activating your account.');

progressBar

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

noty()->progressBar(bool $progressBar = false)
#/ noty progressBar

noty()
    ->progressBar(false)
    ->addSuccess('The operation completed successfully.');

closeWith

click, button

Default click

noty()->closeWith(string|array $closeWith)
#/ noty closeWith

noty()
    ->closeWith(['click', 'button'])
    ->addError('There was an issue adding your item to the cart.');

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.

noty()->animation(string $animation, string $effect)
#/ noty animation

noty()
    ->animation(null)
    ->addError('There was a problem re-activating your account.');

sounds

sources : Array of audio sources e.g ‘some.wav’
volume : nteger value between 0-1 e.g 0.5
conditions : There are two conditions for now: ‘docVisible’ & ‘docHidden’. You can use one of them or both.

noty()->sounds(string $option, mixed $value)
#/ noty sounds

noty()
    ->sounds('sources', ['/dist/sounds/notification.wav'])
    ->sounds('volume', 0.3)
    ->sounds('conditions', ['docVisible', 'docHidden'])
    ->addInfo('Your review has been submitted and is being reviewed.');

docTitle

There are two conditions for now: docVisible & docHidden. You can use one of them or both.

noty()->docTitle(string $option, mixed $docTitle)
#/ noty docTitle

noty()
    ->docTitle('conditions', ['docVisible', 'docHidden'])
    ->addSuccess('Your account has been reactivated.');

modal

noty()->modal(bool $modal = true)
#/ noty modal

noty()
    ->modal(true)
    ->addWarning('Your device may not have been registered.');

id

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

noty()->id(bool|string $id)
#/ noty id

noty()
    ->id(false)
    ->addWarning('Your password may not have been changed.');

force

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

noty()->force(bool $force = true)
#/ noty force

noty()
    ->force(false)
    ->addSuccess('Your feedback has been submitted.');

queue

NEW Named queue system. Details are here.

noty()->queue(string $queue)

Default: global

#/ noty queue

noty()
    ->queue('global')
    ->addInfo('Your account has been un-suspended and a confirmation email has been sent.');

killer

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

noty()->killer(bool|string $killer)
#/ noty killer

noty()
    ->killer(true)
    ->addWarning('Your question may not have been submitted.');

container

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

noty()->container(bool|string $container)
#/ noty container

noty()
    ->container(false)
    ->addInfo('Your order has been placed and is being processed.');

visibilityControl

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

noty()->visibilityControl(bool $visibilityControl)
#/ noty visibilityControl

noty()
    ->visibilityControl(true)
    ->addSuccess('Your account has been reactivated.');
Younes

PHPFlasher is a project by Younes KHOUBZA.