x00 / ntfy-php
Send notifications to your phone in one line via Ntfy.sh for Symfony
v2.3.10
2026-01-28 14:52 UTC
Requires
- php: >=7.4
- composer-plugin-api: ^2.0
- ext-curl: *
- symfony/config: ^5.4 || ^6.0 || ^7.0
- symfony/dependency-injection: ^5.4 || ^6.0 || ^7.0
- symfony/http-kernel: ^5.4 || ^6.0 || ^7.0
- symfony/yaml: ^5.4 || ^6.0 || ^7.0
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