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()->addWarning('Warning: This may be irreversible.');
    }
}

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')
    ->addError('There was an issue processing your payment.');

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('There was an issue restoring your account.');

noty()
    ->theme('mint')
    ->addWarning('Warning: Proceed with caution.');

noty()
    ->theme('mint')
    ->addInfo('Your contact has been removed 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('Your account has been re-activated.');

noty()
    ->theme('relax')
    ->addError('Something went wrong.');

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

noty()
    ->theme('relax')
    ->addInfo('Your file has been uploaded and is being processed.');
#/ noty theme metroui

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

noty()
    ->theme('metroui')
    ->addSuccess('Your request has been received.');

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

noty()
    ->theme('metroui')
    ->addWarning('Your account may not have been re-activated.');

noty()
    ->theme('metroui')
    ->addInfo('Your review has been posted and is being reviewed.');
#/ noty theme light

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

noty()
    ->theme('light')
    ->addSuccess('Your account has been re-activated.');

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

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

noty()
    ->theme('light')
    ->addInfo('Your order has been shipped and a tracking number has been sent to your email.');
#/ noty theme sunset
// Theme: https://github.com/needim/noty/blob/master/lib/themes/sunset.css

noty()
    ->theme('sunset')
    ->addSuccess('Your contact has been removed.');

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

noty()
    ->theme('sunset')
    ->addWarning('Caution: May have unintended results.');

noty()
    ->theme('sunset')
    ->addInfo('Your feedback has been received and is being reviewed.');

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 file has been uploaded and is being processed.');

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 a problem re-activating your account.');

closeWith

click, button

Default click

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

noty()
    ->closeWith(['click', 'button'])
    ->addError('There was a problem sending your message.');

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 an issue reactivating 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 password has been changed and a confirmation email has been sent.');

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'])
    ->addWarning('Your order may not have been placed.');

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

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)
    ->addError('There was an issue deactivating your account.');

queue

NEW Named queue system. Details are here.

noty()->queue(string $queue)

Default: global

#/ noty queue

noty()
    ->queue('global')
    ->addInfo('Your account has been de-registered 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)
    ->addInfo('Your product has been shipped and a tracking number has been sent to your email.');

container

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

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

noty()
    ->container(false)
    ->addError('There was an issue unlocking your account.');

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)
    ->addError('There was a problem changing your password.');
Younes

PHPFlasher is a project by Younes KHOUBZA.