PHPackages                             sparkinzy/dcat-websocket - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. sparkinzy/dcat-websocket

ActiveLibrary[HTTP &amp; Networking](/categories/http)

sparkinzy/dcat-websocket
========================

为Dcat Admin 一键集成websocket功能

1.0.1(3y ago)1004MITJavaScriptPHP &gt;=7.1.0

Since Nov 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Sparkinzy/dcat-websocket)[ Packagist](https://packagist.org/packages/sparkinzy/dcat-websocket)[ Docs](https://github.com/sparkinzy/dcat-websocket)[ RSS](/packages/sparkinzy-dcat-websocket/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Dcat Admin Extension
====================

[](#dcat-admin-extension)

1.安装依赖包
-------

[](#1安装依赖包)

```
# 依赖以下扩展包
composer require pusher/pusher-php-server "~4.0"
composer require beyondcode/laravel-websockets
# 发布相关文件 如 config/websockets.php
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider"
```

2.添加配置 .env
-----------

[](#2添加配置-env)

```
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=sparkinzy
PUSHER_APP_KEY=sparkinzy
PUSHER_APP_SECRET=sparkinzy
LARAVEL_WEBSOCKETS_PORT=2022

```

3.修改配置
------

[](#3修改配置)

首先要把 config/app.php 中的 App\\Providers\\BroadcastServiceProvider::class 注释打开

且 注释 App\\Providers\\BroadcastServiceProvider::class 中的 Broadcast::routes();

```
class BroadcastServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
//        Broadcast::routes();

        require base_path('routes/channels.php');
    }
}
```

4.添加私有渠道授权(公共渠道可忽略此步骤)
----------------------

[](#4添加私有渠道授权公共渠道可忽略此步骤)

在 routes/channels.php 中加入我们最开始，在前端 JS 中写的监听频道：

```
Broadcast::channel('room', function () {
    return true;
});
```

### 5.广播配置

[](#5广播配置)

在 config/broadcasting.php 中的 connections.pusher 下加入两个配置信息：

```
'connections' => [
    'pusher' => [
        'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'useTLS' => true,
                // 拦截 pusher 的广播后，转发到目标 ip
                'host' => '127.0.0.1',
                // 转发的端口，就是我们之前在 .env 文件中配置的 2022 端口
                'port' => env('LARAVEL_WEBSOCKETS_PORT', 2022),
            ],
    ];
];
```

6.启动socket监听
------------

[](#6启动socket监听)

```
php artisan websockets:serve --port=2022
```

Admin/bootstrap.php 启用
----------------------

[](#adminbootstrapphp-启用)

```
$user_id = Admin::user()->id ?? 0;
Admin::script({
      console.log(e)
  })

JS
);
```

前端向后端发送消息
---------

[](#前端向后端发送消息)

```
// 这里新增一个向服务端发送消息的方法
// 第一个参数是事件名，这个可以随意写，不需要与 Laravel 中做对应
// 第二个参数是具体数据，这个就更随意了
DcatEcho.connector.pusher.send_event('hi_girl', {
    my_name: 'LiamHao',
    my_height: 180,
});
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1286d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/16fc8fbed8bb57e44315814548964d441eb425c5b0c8eb16bf036a3e99d960dc?d=identicon)[sparkinzy](/maintainers/sparkinzy)

---

Top Contributors

[![Sparkinzy](https://avatars.githubusercontent.com/u/8643392?v=4)](https://github.com/Sparkinzy "Sparkinzy (3 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

websocketextensiondcat admin

### Embed Badge

![Health badge](/badges/sparkinzy-dcat-websocket/health.svg)

```
[![Health](https://phpackages.com/badges/sparkinzy-dcat-websocket/health.svg)](https://phpackages.com/packages/sparkinzy-dcat-websocket)
```

###  Alternatives

[chrome-php/wrench

A simple PHP WebSocket implementation

673.7M4](/packages/chrome-php-wrench)[joni-jones/yii2-wschat

Online chat based on web sockets and ratchet php

981.3k](/packages/joni-jones-yii2-wschat)[immusen/yii2-swoole-websocket

Websocket server for Yii2 base on swoole 4, Support JSONRPC, Resolve 'method' as a route reflect into controller/action, And support http or redis pub/sub to trigger async task from your web application.

338.8k](/packages/immusen-yii2-swoole-websocket)[kyrne/websocket

Integrated Pusher replacement.

121.6k1](/packages/kyrne-websocket)[yiiplus/yii2-websocket

使用yii2封装 websocket 扩展

212.6k](/packages/yiiplus-yii2-websocket)[voryx/websocketmiddleware

WebSocket Middleware for React

2669.2k3](/packages/voryx-websocketmiddleware)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
