Looking to hire Laravel developers? Try LaraJobs

pushctl-laravel maintained by pushctl

Description
Push notifications for developers
Authors
Last update
2026/08/14 10:56 (dev-master)
License
Downloads
6

Comments
comments powered by Disqus

Push notifications for developers

Installation

You can install the package via Composer:

composer require pushctl/pushctl-laravel

You may publish all of the package's resources at once:

php artisan vendor:publish --tag="pushctl"

Or, you may publish each resource individually:

Publishing the Configuration File

php artisan vendor:publish --tag="pushctl-config"

Usage

Configure the Pushctl API URL and an application token with the notifications:send ability:

PUSHCTL_TOKEN=your-application-token

Add the Pushctl channel to a Laravel notification and return a fluent message from toPushctl:

use Pushctl\PushctlLaravel\Channels\PushctlChannel;
use Pushctl\PushctlLaravel\Messages\PushctlMessage;
use Illuminate\Notifications\Notification;

final class OrderReady extends Notification
{
    public function __construct(private readonly Order $order) {}

    public function via(object $notifiable): array
    {
        return [PushctlChannel::class];
    }

    public function toPushctl(object $notifiable): PushctlMessage
    {
        return PushctlMessage::create('Order ready', 'Your order is ready for collection.')
            ->actionUrl("myapp://orders/{$this->order->id}")
            ->with('order_id', $this->order->id)
            ->ttl(3600)
            ->priority('high')
            ->collapseId("order-{$this->order->id}");
    }
}

Route a notifiable model to its external Pushctl user ID. An array may be returned when one notification should target multiple external users.

use Illuminate\Notifications\Notification;

public function routeNotificationForPushctl(Notification $notification): string|array
{
    return $this->pushctl_user_id;
}

Pushctl supports visible and data-only messages. The builder also provides imageUrl, data, sound, badge, androidChannelId, iosCategory, ios, android, and idempotencyKey methods.

Messages can also be sent directly:

use Pushctl\PushctlLaravel\Pushctl;

app(Pushctl::class)->send(
    PushctlMessage::create('Hello')->with('context', 'welcome'),
    ['external-user-1', 'external-user-2'],
);

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing to Pushctl Laravel Sdk! Please review our contributing guide to get started.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

Pushctl Laravel Sdk is open-sourced software licensed under the MIT license.