承接 simple-ipc/php-symplib 相关项目开发

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

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

simple-ipc/php-symplib

最新稳定版本:v1.0.1

Composer 安装命令:

composer require simple-ipc/php-symplib

包简介

Synchronous Message Passing Framework for PHP

关键字:

README 文档

README

User-friendly, object-oriented API for message passing between PHP processes.

Stream sockets are used as message passing channels. A single server can listen for and handle messages on multiple channels, which can include any mix of Unix domain sockets and TCP/IP (v4 and v6).

Protocol

Messages use a simple wire protocol, where the first 8 bytes of the message specify the length of the rest of the message (unsigned, big endian).

The payload of the message is provided by the user. Serialization format etc. is left to user’s choice.

Getting started

See full working examples in the test/ directory.

Simple server

class MyMessageHandler implements MessageHandler {
    public function handleMessage(string $msg): string {
        return "Hello, client, I received: $msg";
    }
}

$handler = new MyMessageHandler();
$address = new InetSocketAddress('127.0.0.1', 1389, AF_INET);
$server = new SocketStreamsServer([
    new SocketData($address, $handler)
]);

$server->listen();
while (true)
    $server->checkMessages(1);

Simple client

$address = new InetSocketAddress('127.0.0.1', 1389);
$client = new SocketStreamClient($address);

$client->connect();
$client->sendMessage("Hello, server!");
$response = $client->receiveMessage();
echo $response . PHP_EOL;
$client->disconnect();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-03-26