Download the PHP package simple-ipc/php-symplib without Composer
On this page you can find all versions of the php package simple-ipc/php-symplib. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simple-ipc/php-symplib
More information about simple-ipc/php-symplib
Files in simple-ipc/php-symplib
Package php-symplib
Short Description Synchronous Message Passing Framework for PHP
License BSD-3-Clause
Informations about the package php-symplib
= Synchronous Message Passing framework for PHP
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
[source,php]
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
[source,php]
$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();
All versions of php-symplib with dependencies
ext-sockets Version *