定制 vask/laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vask/laravel

最新稳定版本:0.0.16

Composer 安装命令:

composer require vask/laravel

包简介

Pusher-compatible websockets powered by vask.dev

README 文档

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.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固