Laravel Desktop Notifier

Laravel Desktop Notifier

Laravel Desktop Notifier is a package by Nuno Maduro to send notifications to your desktop from Artisan commands:

public function handle()
{
    $this->notify('Hello Web Artisan', 'Love beautiful code? We do too!');
    // Icons anyone?
    $this->notify(
        'With a logo!',
        'This has a logo',
        resource_path('path/to/icon.png')
    );    
}

The first example would look something like this on macOS:

Under the hood, this package uses the a macro to add the notify method to console commands:

Command::macro('notify', function (string $text, string $body, $icon = null) {
    $notifier = $this->laravel[Contracts\Notifier::class];

    $notification = $this->laravel[Contracts\Notification::class]
        ->setTitle($text)
        ->setBody($body);

    if ( ! empty($icon)) {
        $notification->setIcon($icon);
    }

    $notifier->send($notification);
});

As you can see, the first argument is the notification title, followed by the notification body and the optional icon.

If you’re interested in integrating desktop notifications in a PHP package, this package uses the excellent JoliNotif. Desktop notifications work across Linux, Windows, and macOS!

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in: Laravel Packages / laravel / packages

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Software Developer
Remote (US & Canada)
Alley
😎 Laravel Developer
Remote
Jogg, Inc
Junior, Mid, and Senior Software Engineers. Laravel / Vue. Saint Petersburg, FL
Saint Petersburg, FL and Remote
ShineOn
Senior PHP Developer (Laravel)
Remote
The Interaction Design Foundation
Fullstack Laravel Engineer (Munich/Remote) 💻
Munich, Germany or Remote
AirLST GmbH