├── .styleci.yml ├── LICENSE ├── README.md ├── composer.json └── src ├── Contracts ├── Notification.php └── Notifier.php ├── Facades └── Notifier.php ├── LaravelDesktopNotifierServiceProvider.php ├── Notification.php └── Notifier.php /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Nuno Maduro 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

6 | StyleCI Status 7 | Build Status 8 | Quality Score 9 | Latest Version 10 | License 11 |

12 | 13 | ## About Laravel Desktop Notifier 14 | 15 | Laravel Desktop Notifier was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is a [JoliNotif](https://github.com/jolicode/JoliNotif) wrapper for Laravel Console Commands. Works on Linux, Windows & MacOS. 16 | 17 | ## Installation 18 | 19 | > **Requires [PHP 8.1+](https://php.net/releases)** 20 | 21 | Require Laravel Desktop Notifier using [Composer](https://getcomposer.org): 22 | 23 | ```bash 24 | composer require nunomaduro/laravel-desktop-notifier 25 | ``` 26 | 27 | ## Usage 28 | 29 | Once installed, the `notify()` method macro will be available in any of your Artisan commands. 30 | 31 | ```php 32 | class ZondaCommand extends Command 33 | { 34 | public function handle() 35 | { 36 | $this->notify('Hello Web Artisan', 'Love beautiful code? We do too!'); 37 | } 38 | } 39 | ``` 40 | 41 | You can add an icon to the notification by passing a 3rd argument with the path to the icon: 42 | 43 | ```php 44 | $this->notify('With a logo!', 'This has a logo', resource_path('path/to/icon.png')); 45 | ``` 46 | 47 | To learn more about Artisan commands, see the [Laravel documentation](https://laravel.com/docs/artisan). 48 | 49 | ## Contributing 50 | 51 | Thank you for considering to contribute to Laravel Desktop Notifier. All the contribution guidelines are mentioned [here](CONTRIBUTING.md). 52 | 53 | You can have a look at the [CHANGELOG](CHANGELOG.md) for constant updates & detailed information about the changes. You can also follow the twitter account for latest announcements or just come say hi!: [@enunomaduro](https://twitter.com/enunomaduro) 54 | 55 | ## Support the development 56 | **Do you like this project? Support it by donating** 57 | 58 | - PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L) 59 | - Patreon: [Donate](https://www.patreon.com/nunomaduro) 60 | 61 | ## License 62 | 63 | Laravel Desktop Notifier is an open-sourced software licensed under the [MIT license](LICENSE.md). 64 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nunomaduro/laravel-desktop-notifier", 3 | "description": "Send notifications to your desktop from your Laravel commands. An JoliNotif wrapper for Laravel 5.", 4 | "keywords": [ 5 | "laravel", 6 | "framework", 7 | "console", 8 | "artisan", 9 | "php", 10 | "wrapper", 11 | "JoliNotif", 12 | "notification", 13 | "notifier", 14 | "Nuno Maduro", 15 | "NunoMaduro" 16 | ], 17 | "license": "MIT", 18 | "require": { 19 | "php": "^8.2", 20 | "illuminate/support": "^10.0|^11.0|^12.0", 21 | "illuminate/console": "^10.0|^11.0|^12.0", 22 | "jolicode/jolinotif": "^2.5" 23 | }, 24 | "require-dev": { 25 | "graham-campbell/testbench": "^5.7|^6.2", 26 | "pestphp/pest": "^3.7" 27 | }, 28 | "authors": [ 29 | { 30 | "name": "Nuno Maduro", 31 | "email": "enunomaduro@gmail.com" 32 | } 33 | ], 34 | "autoload": { 35 | "psr-4": { 36 | "NunoMaduro\\LaravelDesktopNotifier\\": "src/" 37 | } 38 | }, 39 | "autoload-dev": { 40 | "psr-4": { 41 | "NunoMaduro\\Tests\\LaravelDesktopNotifier\\": "tests/" 42 | } 43 | }, 44 | "config": { 45 | "preferred-install": "dist", 46 | "allow-plugins": { 47 | "pestphp/pest-plugin": true 48 | } 49 | }, 50 | "extra": { 51 | "laravel": { 52 | "providers": [ 53 | "NunoMaduro\\LaravelDesktopNotifier\\LaravelDesktopNotifierServiceProvider" 54 | ], 55 | "aliases": { 56 | "Notifier": "NunoMaduro\\LaravelDesktopNotifier\\Facaces\\Notifier" 57 | } 58 | } 59 | }, 60 | "minimum-stability": "dev", 61 | "prefer-stable": true 62 | } 63 | -------------------------------------------------------------------------------- /src/Contracts/Notification.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace NunoMaduro\LaravelDesktopNotifier\Contracts; 13 | 14 | /** 15 | * Interface Notification. 16 | * 17 | * @author Nuno Maduro 18 | */ 19 | interface Notification 20 | { 21 | /** 22 | * @return string 23 | */ 24 | public function getTitle(); 25 | 26 | /** 27 | * @return \NunoMaduro\LaravelDesktopNotifier\Contracts\Notification 28 | */ 29 | public function setTitle(string $title): \Joli\JoliNotif\Notification; 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getBody(); 35 | 36 | /** 37 | * @return \NunoMaduro\LaravelDesktopNotifier\Contracts\Notification 38 | */ 39 | public function setBody(string $body): \Joli\JoliNotif\Notification; 40 | 41 | /** 42 | * @return string 43 | */ 44 | public function getIcon(); 45 | 46 | /** 47 | * @return \NunoMaduro\LaravelDesktopNotifier\Contracts\Notification 48 | */ 49 | public function setIcon(string $icon): \Joli\JoliNotif\Notification; 50 | } 51 | -------------------------------------------------------------------------------- /src/Contracts/Notifier.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace NunoMaduro\LaravelDesktopNotifier\Contracts; 13 | 14 | use Joli\JoliNotif\Notifier as BaseNotifier; 15 | 16 | /** 17 | * Interface Notification. 18 | * 19 | * @author Nuno Maduro 20 | */ 21 | interface Notifier extends BaseNotifier 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/Facades/Notifier.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace NunoMaduro\LaravelDesktopNotifier\Facades; 13 | 14 | use Illuminate\Support\Facades\Facade; 15 | 16 | /** 17 | * The is the Laravel Desktop Notifier facade class. 18 | * 19 | * @author Nuno Maduro 20 | */ 21 | class Notifier extends Facade 22 | { 23 | /** 24 | * Get the registered name of the component. 25 | * 26 | * @return string 27 | */ 28 | protected static function getFacadeAccessor() 29 | { 30 | return 'desktop.notifier'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/LaravelDesktopNotifierServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace NunoMaduro\LaravelDesktopNotifier; 13 | 14 | use Illuminate\Console\Command; 15 | use Illuminate\Support\ServiceProvider; 16 | use Joli\JoliNotif\NotifierFactory; 17 | use NunoMaduro\LaravelDesktopNotifier\Contracts\Notification as NotificationContract; 18 | use NunoMaduro\LaravelDesktopNotifier\Contracts\Notifier as NotifierContract; 19 | 20 | /** 21 | * The is the Laravel Desktop Notifier service provider class. 22 | */ 23 | class LaravelDesktopNotifierServiceProvider extends ServiceProvider 24 | { 25 | /** 26 | * {@inheritdoc} 27 | */ 28 | public function boot() 29 | { 30 | /* 31 | * Sends a desktop notification. 32 | * 33 | * @param string $title 34 | * @param string $body 35 | * @param string|null $icon 36 | * 37 | * @return void 38 | */ 39 | Command::macro('notify', function (string $text, string $body, $icon = null) { 40 | $notifier = $this->laravel[Contracts\Notifier::class]; 41 | 42 | $notification = $this->laravel[Contracts\Notification::class] 43 | ->setTitle($text) 44 | ->setBody($body); 45 | 46 | if (! empty($icon)) { 47 | $notification->setIcon($icon); 48 | } 49 | 50 | $notifier->send($notification); 51 | }); 52 | } 53 | 54 | /** 55 | * {@inheritdoc} 56 | */ 57 | public function register() 58 | { 59 | $this->app->singleton('desktop.notifier', function ($app) { 60 | $config = $app['config']['app.notifiers']; 61 | 62 | $notifier = NotifierFactory::create(is_array($config) ? $config : []); 63 | 64 | return new Notifier($notifier); 65 | }); 66 | 67 | $this->app->alias('desktop.notifier', NotifierContract::class); 68 | 69 | $this->app->bind('desktop.notification', function () { 70 | return new Notification(); 71 | }); 72 | 73 | $this->app->alias('desktop.notification', NotificationContract::class); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/Notification.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace NunoMaduro\LaravelDesktopNotifier; 13 | 14 | use Joli\JoliNotif\Notification as BaseNotification; 15 | use NunoMaduro\LaravelDesktopNotifier\Contracts\Notification as NotificationContract; 16 | 17 | /** 18 | * The concrete implementation of the notification. 19 | * 20 | * @author Nuno Maduro 21 | */ 22 | class Notification extends BaseNotification implements NotificationContract 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /src/Notifier.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace NunoMaduro\LaravelDesktopNotifier; 13 | 14 | use Joli\JoliNotif\Notifier as BaseNotifier; 15 | use NunoMaduro\LaravelDesktopNotifier\Contracts\Notifier as NotifierContract; 16 | 17 | /** 18 | * The concrete implementation of the notifier. 19 | * 20 | * @author Nuno Maduro 21 | */ 22 | class Notifier implements NotifierContract 23 | { 24 | /** 25 | * @var \Joli\JoliNotif\Notifier 26 | */ 27 | protected $notifier; 28 | 29 | /** 30 | * Notifier constructor. 31 | */ 32 | public function __construct(BaseNotifier $notifier) 33 | { 34 | $this->notifier = $notifier; 35 | } 36 | 37 | /** 38 | * {@inheritdoc} 39 | */ 40 | public function isSupported(): bool 41 | { 42 | return $this->notifier->isSupported(); 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | */ 48 | public function getPriority(): int 49 | { 50 | return $this->notifier->getPriority(); 51 | } 52 | 53 | /** 54 | * {@inheritdoc} 55 | */ 56 | public function send(\Joli\JoliNotif\Notification $notification): bool 57 | { 58 | return $this->notifier->send($notification); 59 | } 60 | } 61 | --------------------------------------------------------------------------------