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()->addInfo('Your account has been terminated and a confirmation email has been sent.');
    }
}

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 address has been updated and a confirmation email has been sent.');

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('Operation completed successfully.');

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

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

noty()
    ->theme('mint')
    ->addInfo('This may take a while. Do not refresh the page.');
#/ 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('Your account has been unlinked.');

noty()
    ->theme('relax')
    ->addError('There was an issue shipping your product.');

noty()
    ->theme('relax')
    ->addWarning('Your message may not have been received.');

noty()
    ->theme('relax')
    ->addInfo('Your account has been terminated 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 restored.');

noty()
    ->theme('metroui')
    ->addError('There was a problem receiving your message.');

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

noty()
    ->theme('metroui')
    ->addInfo('Your password has been changed 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('Your account has been re-verified.');

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

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

noty()
    ->theme('light')
    ->addInfo('Your message has been received and is being processed.');
#/ noty theme sunset
// Theme: https://github.com/needim/noty/blob/master/lib/themes/sunset.css

noty()
    ->theme('sunset')
    ->addSuccess('Your subscription has been cancelled.');

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

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

noty()
    ->theme('sunset')
    ->addInfo('Heads up: This may take a while. Be patient.');

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
    ->addInfo('Your feedback has been submitted and is being reviewed.');

progressBar

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

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

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

closeWith

click, button

Default click

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

noty()
    ->closeWith(['click', 'button'])
    ->addError('There was an issue suspending your account.');

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)
    ->addSuccess('Your order has been placed.');

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'])
    ->addError('An error occurred.');

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('The operation completed successfully.');

modal

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

noty()
    ->modal(true)
    ->addSuccess('Your account has been re-activated.');

id

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

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

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

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)
    ->addInfo('Your contact has been added and a confirmation email has been sent.');

queue

NEW Named queue system. Details are here.

noty()->queue(string $queue)

Default: global

#/ noty queue

noty()
    ->queue('global')
    ->addInfo('Your account has been unlinked 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 password may not have been set.');

container

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

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

noty()
    ->container(false)
    ->addWarning('Warning: This may be irreversible.');

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 reservation has been confirmed.');
Younes

PHPFlasher is a project by Younes KHOUBZA.