f1ll0y/php-os-gui-notify

在Windows、Linux、MacOS上发送桌面操作系统通知。

3.0.0 2024-02-01 08:19 UTC

This package is not auto-updated.

Last update: 2024-09-27 09:23:20 UTC


README

jolicode/JoliNotif 分支而来

JoliNotif demo

Total Downloads Latest Stable Version Latest Unstable Version

JoliNotif是一个跨平台PHP库,用于显示桌面通知。它支持Linux、Windows或MacOS。

要求PHP >= 7.4(版本1.x支持PHP 5,版本< 2.1.0支持PHP 7.0和7.1,版本< 2.4.0支持PHP 7.2和7.3)。

注意

此库不能在Web环境中使用(FPM或等效)。请在CLI脚本或CRON中使用它

安装

使用Composer将JoliNotif安装到您的项目中

composer require "jolicode/jolinotif"

用法

使用NotifierFactory创建正确的Notifier(适配您的操作系统),然后使用它发送通知

include __DIR__.'/vendor/autoload.php';

use Joli\JoliNotif\Notification;
use Joli\JoliNotif\NotifierFactory;

// Create a Notifier
$notifier = NotifierFactory::create();

// Create your notification
$notification =
    (new Notification())
    ->setTitle('Notification title')
    ->setBody('This is the body of your notification')
    ->setIcon(__DIR__.'/path/to/your/icon.png')
    ->addOption('subtitle', 'This is a subtitle') // Only works on macOS (AppleScriptNotifier)
    ->addOption('sound', 'Frog') // Only works on macOS (AppleScriptNotifier)
;

// Send it
$notifier->send($notification);

还提供了一个shell可执行文件,可以从CLI使用JoliNotif

jolinotif --title "Hello" --body "World"

更多文档

通过阅读文档了解更多

您可以使用以下方式查看当前版本和过去版本

最后是一些元文档

致谢

许可

JoliNotif采用MIT许可证 - 详细信息请参阅LICENSE文件。