承接 amarwave/amarwave-laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

amarwave/amarwave-laravel

Composer 安装命令:

composer require amarwave/amarwave-laravel

包简介

Laravel service provider, facade, and broadcasting driver for AmarWave real-time messaging.

README 文档

README

Laravel service provider, facade, and broadcasting driver for AmarWave real-time messaging.

This package wraps amarwave/amarwave-php and wires it into the Laravel framework.

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12

Installation

composer require amarwave/amarwave-laravel

Laravel auto-discovers the service provider and facade. No manual registration needed.

Configuration

Publish the config file:

php artisan vendor:publish --tag=amarwave-config

Add to your .env:

AMARWAVE_APP_KEY=your-app-key
AMARWAVE_APP_SECRET=your-app-secret
AMARWAVE_CLUSTER=default
AMARWAVE_TIMEOUT=10

Usage

Facade

use AmarWave\Laravel\AmarWave;

AmarWave::trigger('orders', 'placed', ['order_id' => 42]);

AmarWave::triggerBatch([
    ['channel' => 'chat-1', 'event' => 'message', 'data' => ['text' => 'Hello']],
    ['channel' => 'chat-2', 'event' => 'message', 'data' => ['text' => 'World']],
]);

Or with the global alias:

\AmarWave::trigger('orders', 'placed', ['order_id' => 42]);

Dependency Injection

use AmarWave\AmarWave;

class OrderController extends Controller
{
    public function __construct(private readonly AmarWave $aw) {}

    public function store(Request $request): JsonResponse
    {
        $order = Order::create($request->validated());
        $this->aw->trigger('orders', 'placed', $order->toArray());
        return response()->json($order, 201);
    }
}

Broadcasting Driver

Use AmarWave as a Laravel broadcasting driver so broadcast(new YourEvent) works out of the box.

1 — Add the connection to config/broadcasting.php

'connections' => [
    'amarwave' => [
        'driver' => 'amarwave',
    ],
],

2 — Set the driver in .env

# Laravel 10
BROADCAST_DRIVER=amarwave
# Laravel 11+
BROADCAST_CONNECTION=amarwave

3 — Create a broadcastable event

namespace App\Events;

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

class OrderPlaced implements ShouldBroadcast
{
    public function __construct(public readonly array $order) {}

    public function broadcastOn(): array
    {
        return [
            new Channel('orders'),
            new PrivateChannel("user.{$this->order['user_id']}"),
        ];
    }

    public function broadcastAs(): string { return 'order.placed'; }

    public function broadcastWith(): array
    {
        return ['order_id' => $this->order['id'], 'total' => $this->order['total']];
    }
}

4 — Dispatch

broadcast(new OrderPlaced($order));

Channel Authorization

In routes/channels.php:

use Illuminate\Support\Facades\Broadcast;

Broadcast::channel('user.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

Broadcast::channel('presence-room.{roomId}', function ($user, $roomId) {
    $room = \App\Models\Room::find($roomId);
    if ($room?->members()->where('user_id', $user->id)->exists()) {
        return ['id' => $user->id, 'name' => $user->name];
    }
    return false;
});

License

MIT

amarwave/amarwave-laravel 适用场景与选型建议

amarwave/amarwave-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 amarwave/amarwave-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 amarwave/amarwave-laravel 我们能提供哪些服务?
定制开发 / 二次开发

基于 amarwave/amarwave-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-09