Skip to content

krydos/websocket-php

 
 

Repository files navigation

Websocket Client for PHP

Build Status Coverage Status

This package mainly contains a WebSocket client for PHP.

I made it because the state of other WebSocket clients I could found was either very poor (sometimes failing on large frames) or had huge dependencies (React…).

The Client should be good. If it isn't, tell me!

The Server there because much of the code would be identical in writing a server, and because it is used for the tests. To be really useful though, there should be a Connection-class returned from a new Connection, and the Server-class only handling the handshake. Then you could hold a full array of Connections and check them periodically for new data, send something to them all or fork off a process handling one connection. But, I have no use for that right now. (Actually, I would suggest a language with better asynchronous handling than PHP for that.)

Install

# Install composer
curl -s http://getcomposer.org/installer | php

# Generate vendor/autload.php
php composer.phar install --no-dev

Client usage:

require('vendor/autoload.php');

use WebSocket\Client;

$client = new Client("ws://echo.websocket.org/");
$client->send("Hello WebSocket.org!");

echo $client->receive(); // Will output 'Hello WebSocket.org!'

About

WebSocket client and server in PHP

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%