Native clients
Connect JavaScript and PHP applications to the native Conveyor protocol, with version-specific setup and migration notes.
Release status
PHP client 0.2.0 is published on Packagist. JS 2.0.1 is planned; publication pending. The JavaScript example below describes that candidate; the PHP section documents the published release. See ecosystem release status and Composer namespace migration.
Start the native Quick Start server on 127.0.0.1:8989 first. These clients exchange native JSON actions, not Pusher events, and do not replace Laravel Echo + pusher-js.
JavaScript · 2.0.1 planned
Package: socket-conveyor-client. Source and release notes: firebrikdotcom/socket-conveyor-client. Use a modern browser with ES modules and WebSocket, or Node 22+ with its global WebSocket. A bundler resolves the bare import below; a browser module can instead import a locally served package file. Use wss on HTTPS pages. Acknowledgements additionally require crypto.randomUUID() in a secure browser context.
import Conveyor from 'socket-conveyor-client';
const connection = new Conveyor({
uri: '127.0.0.1',
port: 8989,
channel: 'sample-channel',
onReady: () => connection.send('Hello from JS', 'broadcast-action'),
onMessage: (data, fd) => console.log(data, fd),
onError: (error) => console.error(error),
});
// When the application is done:
// connection.close();send(message, action) defaults to base-action; this example selects broadcast-action explicitly. onMessage receives parsed data and fd; onRawMessage receives the original JSON text. Render untrusted message text with textContent. Sends before OPEN are ignored without buffering.
PHP · 0.2.0 published
composer require firebrikdotcom/conveyor-server-client:0.2.0Composer package: firebrikdotcom/conveyor-server-client (0.2.0 published). Source and release notes: firebrikdotcom/conveyor-server-client. The release requires PHP ^8.3, Composer 2 and OpenSwoole ^26.2 (>=26.2, <27). Its transport dependency remains textalk/websocket ^1.6.3. TLS needs OpenSSL. Development with PHPUnit 13 requires PHP 8.4.1+; that is separate from the consumer runtime requirement.
<?php
require __DIR__ . '/vendor/autoload.php';
use Kanata\ConveyorServerClient\Client;
$client = new Client([
'uri' => '127.0.0.1',
'port' => 8989,
'channel' => 'sample-channel',
'timeout' => 30,
'onReadyCallback' => function (Client $client): void {
$client->send('Hello from PHP');
},
'onMessageCallback' => function (Client $client, string $message): void {
echo $message, PHP_EOL;
$client->close();
},
]);
$client->connect();connect() runs the receive loop. Send after connecting, for example in onReadyCallback. send() wraps a string in a broadcast-action envelope; sendRaw() sends an exact string. The message callback receives raw text. timeout is a socket read timeout in seconds, not a total session deadline; -1 selects unlimited reads. Configure retries explicitly if needed.
Upgrade checklist
- JS 1.2.9 → 2.0.1: use ESM
import, or dynamicimport()from CommonJS. Supply the original auth token rather than a pre-encoded token. Invalid incoming messages reachonError. Callclose()to stop timers and reconnect attempts. Historicallisten,setOptionandonReconnectCallbackAPIs are not supported. - PHP 0.1.6 → 0.2.0: provision PHP 8.3+ and OpenSwoole >=26.2, <27, review retry/timeout behavior, and send only after connecting. Invalid UTF-8 payload encoding throws
JsonException. UseonReadyCallback; the historicallistenandonOpenCallbackoptions are not supported. - Check the selected release notes, resolve dependencies in your own application, then smoke-test channel join, delivery, disconnect and reconnect against your native server before deploying.
For authorization, see server and channel tokens. Keep server secrets on the backend; provide browser channel tokens only after application authorization.