x00/ntfy-php
最新稳定版本:v2.3.10
Composer 安装命令:
composer require x00/ntfy-php
包简介
Send notifications to your phone in one line via Ntfy.sh for Symfony
README 文档
README
Send notifications to your phone in one line via ntfy.sh.
Installation
Install the package via Composer:
composer require x00/ntfy-php
Note
During installation, you may be asked to allow the x00/ntfy-php plugin. This is required to automatically generate the configuration file.
Configuration
The library now supports zero-configuration for Symfony projects.
Automatic Notifications Channels (Symfony)
Upon installation, a default configuration file is automatically created at config/packages/ntfy.yaml. You just need to update it with your channel IDs:
ntfy: silent: false # Optional: If true, swallows exceptions on failure. Default: false channels: error: id: 'your-error-channel-id' dev_only: true log: id: 'your-log-channel-id' dev_only: true # Optional: Only send in 'dev' environment urgent: id: 'your-urgent-channel-id' dev_only: false
Environment Variables
Alternatively, you can use environment variables without any configuration file:
NTFY_ERROR_CHANNELNTFY_LOG_CHANNELNTFY_URGENT_CHANNEL
Usage
Use the Ntfy\Core\Ntfy interface to send notifications.
Regular Notifications
use Ntfy\Core\Ntfy; class MyService { public function __construct( private Ntfy $notifier ) {} public function doSomething() { // Send to log channel $this->notifier->send(message: 'Something happened'); // Send with data $this->notifier->send(message: 'Something happened', data: ['key' => 'value']); // Send to specific channel $this->notifier->send(message: 'Something happened', channelId: 'my-custom-channel-id', data: ['key' => 'value']); } }
Exception Notifications
try { // ... } catch (\Throwable $e) { $this->notifier->exception($e, ['user_id' => 123, 'context' => 'foo']); }
Urgent Notifications
$this->notifier->urgent(new \Exception('Server is down!'));
License
Apache-2.0
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2026-01-20