f1ll0y / php-os-gui-notify
在Windows、Linux、MacOS上发送桌面操作系统通知。
3.0.0
2024-02-01 08:19 UTC
Requires
- php: >=8.1
- jolicode/php-os-helper: ^0.1.0
- symfony/process: ^5.4 || ^6.0 || ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- symfony/finder: ^5.4 || ^6.0 || ^7.0
- symfony/phpunit-bridge: ^5.4 || ^6.0 || ^7.0
This package is not auto-updated.
Last update: 2024-09-27 09:23:20 UTC
README
由 jolicode/JoliNotif 分支而来
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"
更多文档
通过阅读文档了解更多
您可以使用以下方式查看当前版本和过去版本
git tag
命令- Github上的发布页面
- 列出版本之间变更的文件
最后是一些元文档
致谢
- 所有贡献者
- 该项目最初受到mikaelbr/node-notifier的启发
许可
JoliNotif采用MIT许可证 - 详细信息请参阅LICENSE文件。