x00/ntfy-php

Send notifications to your phone in one line via Ntfy.sh for Symfony

Maintainers

Package info

github.com/hbdeveloppeur/Ntfy-php

Type:composer-plugin

pkg:composer/x00/ntfy-php

Statistics

Installs: 45

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.3.10 2026-01-28 14:52 UTC

This package is auto-updated.

Last update: 2026-03-28 15:10:17 UTC


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