承接 grok-s/socket 相关项目开发

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

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

grok-s/socket

最新稳定版本:1.0.0

Composer 安装命令:

composer require grok-s/socket

包简介

Full-featured, open-source WebSocket library for PHP (Socket.IO-like: events, rooms, ACKs, auth, encryption, DB integration)

README 文档

README

Pure PHP, Socket.IO-like WebSocket server with:

  • Events, rooms, namespaces
  • One-to-one & group chat
  • Broadcasting
  • JWT Auth middleware
  • AES-256 encryption
  • Database integration
  • Auto-reconnect client
  • Full PHPDoc (VS Code hover)
  • Laravel ready

Install

composer require grok-s/socket

Why GrokSocket?

  • Easy to Use: API like Socket.IO for quick setup.
  • Full Features: Events, rooms (for chats), broadcasting, ACKs, middleware (auth), encryption (AES-256), DB examples.
  • Integrations: Plain PHP, Laravel (service provider), others.
  • Secure: WSS, message encryption.
  • Open-Source: MIT – contribute on GitHub!

Example code and image

image

here is example code running from php ws/server.php start you can copy these code and try to connect with same ip address or localhost with port

<?php
require 'vendor/autoload.php';

use Grok\Socket\Server;

$server = new Server('127.0.0.1', 8282);
// $server->setEncryptionKey('your-secret-key-here');  // Optional: AES-256

// Basic event handling
$server->on('connection', function($socket) {
    echo "Client connected: " . $socket->getId() . "\n";
    $socket->emit('welcome', 'Hello from GrokSocket!');
});


$server->on('chat', function($client, $data) use ($server) {
    echo "Message from " . $client->getId() . ": " . (is_string($data) ? $data : json_encode($data)) . "\n";
});

$server->on('disconnect', function($client) {
    echo "Client disconnected: " . $client->getId() . "\n";
});


$server->run();  // Starts the server

to learn more explore docs and example folder, you can use it with any production application.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-28