承接 x00/ntfy-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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_CHANNEL
  • NTFY_LOG_CHANNEL
  • NTFY_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
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-01-20