PHP WebSockets

PHP WebSocket server

Introduction

websocket-lifecycle

WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. Therefore with WebSocket protocol you can create web chats, real-time notifications or even online games.

This component provide 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)

ollyxar websockets

Installation

Requirements

The recommended way to install WebSockets is through Composer. Here is requirements for this component:

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 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: