vask/laravel

Pusher-compatible websockets powered by vask.dev

Maintainers

Package info

github.com/vask-dev/laravel

pkg:composer/vask/laravel

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 4

0.0.16 2026-05-12 13:31 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Drop-in Laravel integration for Vask, Pusher-compatible WebSockets running on Cloudflare. Run php artisan vask:install to OAuth into your account, write PUSHER_* credentials to .env, and verify the connection in one go. The package also ships a webhook handler for channel, presence, and client events, a vask:doctor diagnostic command, and a local-only /_vask/demo page that proves the round-trip end-to-end.

Installation

composer require vask/laravel

Sign up (or sign in) and wire credentials into .env in one command:

php artisan vask:install

This kicks off an OAuth device flow. You'll be shown a URL and a short code to approve in your browser. Once approved, the command writes PUSHER_* credentials to .env and runs vask:doctor to confirm the configuration. No git config or local tokens are used to authenticate.

If you need to verify an existing setup at any time:

php artisan vask:doctor
php artisan vask:doctor --no-ping --no-broadcast   # skip the live network checks

Try it in the browser

After vask:install, start your dev server and visit /_vask/demo. It's a local-only page that subscribes to a private channel and lets you click emoji to broadcast them, both via the server (POST to Laravel) and as Pusher client events straight from the browser. It exercises the full round-trip (Laravel to Vask to browser) and shows you the latency, so you can confirm both your server credentials and the WebSocket leg without writing a single line of frontend code.

The demo route is only registered when app()->environment() === 'local'. To turn it off entirely, set VASK_NO_DEMO=true in your .env.

Usage

Vask is a drop-in Pusher replacement, so use Laravel's standard broadcasting:

use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class OrderShipped implements ShouldBroadcast
{
    public function broadcastOn(): PrivateChannel
    {
        return new PrivateChannel('orders.'.$this->order->id);
    }
}

Webhooks

Register handlers in a service provider. The package auto-registers POST /webhooks/vask the first time it sees a handler. No handler, no route:

use Vask\Laravel\Facades\Vask;
use Vask\Laravel\Webhooks\Payloads\ChannelOccupiedPayload;

public function boot(): void
{
    Vask::onChannelOccupied(fn (ChannelOccupiedPayload $event) => /* ... */);
    Vask::onMemberAdded([MemberHandler::class, 'joined']);
    Vask::onClientEvent(LogClientEvent::class); // invokable class
}

The route is registered outside the web middleware group, so CSRF doesn't apply. To customise: Vask::webhookPath('/api/vask-hooks') or Vask::disableAutoWebhookRoute() to register your own.

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

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

Credits

License

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