PHP WebSocket server
Introduction
WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. Therefore with WebSocket protocol, you can create webchats, real-time notifications or even online games.
This component provides you easy access to all features of this protocol. Even more - you can send data, not from client-size. You can send data from your PHP application to defined unix-socket (created within component)
Installation
Requirements
The recommended way to install WebSockets is through Composer. Here is requirements for this component:
- Linux (cause of
pcntl_fork) - Composer
Installing WebSockets
Next, run the Composer command to install the latest stable version of WebSockets:
After installing, you need to require Composer's autoloader:
Features
Main features
The WebSockets component has all defined features from the WebSocket protocol. And in addition, it also has communication socket (to send data from PHP or somewhere else) via unix-socket
Customizing
Simple implementation of WebSocket server:
Communicate with server outside the wss protocol:
Client-side markup: