Introduction
Getting started
Socket Conveyor is a high-performance WebSocket server for PHP, built on OpenSwoole. Use the native protocol for speed and control, or run it in Pusher/Reverb-compatible mode for seamless Laravel Echo support.
Choose a mode
Use Pusher/Reverb-compatible mode when you want Laravel broadcasting, Laravel Echo, private channels, presence channels, whispers, and toOthers() with the stock Laravel reverb or pusher connection.
Use native Conveyor mode when you want direct JSON WebSocket actions such as channel-connect, broadcast-action, fanout-action, presence messages, acknowledgments, and custom PHP action handlers.
Install
1composer require kanata-php/socket-conveyorYou also need PHP 8.2 or newer and ext-openswoole 22.0 or newer.
Smallest native server
Create server.php:
1<?php
2
3use Conveyor\Constants;
4use Conveyor\ConveyorServer;
5
6require __DIR__ . '/vendor/autoload.php';
7
8(new ConveyorServer())
9 ->host('127.0.0.1')
10 ->port(8989)
11 ->conveyorOptions([
12 Constants::WEBSOCKET_SUBPROTOCOL => Constants::SOCKET_CONVEYOR,
13 ])
14 ->start();Run it:
1php server.phpConnect with a browser WebSocket:
1const ws = new WebSocket('ws://127.0.0.1:8989')
2
3ws.onmessage = event => console.log(event.data)
4
5ws.onopen = () => {
6 ws.send(JSON.stringify({ action: 'channel-connect', channel: 'chat.room.1' }))
7 ws.send(JSON.stringify({ action: 'broadcast-action', data: 'hello' }))
8}Next: read Installation, then Quick Start. For Laravel Echo, go straight to Laravel Echo / Reverb.


