petecoop/gotify

Gotify notifications channel for Laravel

Maintainers

Package info

github.com/petecoop/gotify

Homepage

pkg:composer/petecoop/gotify

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-08-11 15:37 UTC

This package is auto-updated.

Last update: 2026-08-11 15:50:09 UTC


README

This package makes it easy to send notifications using Gotify with Laravel.

Contents

Installation

You can install the package via composer:

composer require petecoop/gotify

Setting up your Gotify Application

Create an application in your Gotify Server add the following to your config/services.php:

'gotify' => [
    'url' => env('GOTIFY_URL', 'https://gotify.example.com'),
    'token' => env('GOTIFY_TOKEN'),
],

Usage

Direct messages

Use the facade to build and immediately send a message using the default Gotify configuration:

use Petecoop\Gotify\Facades\Gotify;

Gotify::message('Version 2 is live.')
    ->title('Deployment complete')
    ->highPriority()
    ->send();

Call queue() instead to dispatch a generic queued job. The message payload is serialized without the Gotify credentials; the job resolves the configured client when it runs:

Gotify::message('Version 2 is live.')
    ->title('Deployment complete')
    ->queue();

An optional connection and queue may be selected with named arguments:

Gotify::message('Version 2 is live.')
    ->queue(connection: 'redis', queue: 'developer-alerts');

Laravel Notifications

With Laravel Notifications you can use the channel in your via() method, and then define a toGotify() method to build the message:

use Petecoop\Gotify\GotifyMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via(object $notifiable): array
    {
        return ['gotify'];
    }

    public function toGotify(object $notifiable): GotifyMessage
    {
        return GotifyMessage::make('The invoice has been paid.')
            ->title('Invoice paid')
            ->lowPriority()
            ->url('http://example.com/invoices');
    }
}

See Per-user credentials below for how to send to different Gotify servers or applications per user.

Do not call send() or queue() on the message returned by toGotify(); Laravel's notification channel handles its delivery. Both methods report this with a descriptive exception if called on a notification message.

Available Message methods

Method Description
title($title) Set the title of the notification.
message($message) Set the message body of the notification.
url($url) Set the URL to open when the notification is clicked.
image($url) Set the image URL to display in the notification.
androidIntent($url) Set the Android intent to open when the notification is received.
plainText() Set the message format to plain text. (Default)
markdown() Set the message format to markdown.
priority($priority) Set the priority of the notification. (0-10) Defaults to 5.
lowestPriority() or withoutNotification() Set the priority to 0.
lowPriority() Set the priority to 2.
normalPriority() Set the priority to 5. (Default)
highPriority() Set the priority to 8.
highestPriority() or emergency() Set the priority to 10.
extras($extras) Set any additional extras for the notification.
gotifyUrl($url) Override the configured Gotify server URL for this message.
token($token) Override the configured Gotify application token for this message.
send() Immediately send a message created through Gotify::message().
queue($connection, $queue) Queue such a message, optionally selecting its connection and queue.

Per-user credentials

By default, the channel uses the URL and application token in services.gotify. This is convenient when Gotify is only used for a single recipient, such as developer or administrator notifications.

Because each Gotify application token delivers to its owner's clients, a notifiable can override the token on a per-user basis by implementing routeNotificationForGotify:

use Illuminate\Notifications\Notification;

// On your User model (or another notifiable model)
public function routeNotificationForGotify(Notification $notification): string|false|null
{
    return $this->receives_gotify_notifications
        ? $this->gotify_token
        : false;
}

Return an array when the user also needs a different Gotify server:

public function routeNotificationForGotify(Notification $notification): array
{
    return [
        'url' => $this->gotify_url,
        'token' => $this->gotify_token,
    ];
}

The URL and token are independently optional in the array: a missing or null value falls back to the matching value in services.gotify. Return false to explicitly skip Gotify delivery for that notifiable.

Testing

composer test

Security

If you discover any security related issues, please email pete@petecoop.co.uk instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.