Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 935 Bytes

README.md

File metadata and controls

32 lines (26 loc) · 935 Bytes

php-ws

PHP extension for writing WebSocket servers in PHP.

Autobahn WebSocket Test Suite Report

Build Status

Feel like writing your WebSocket servers in PHP? Why not.

<?php
$ws = new WebSocketServer();
$ws->bind("0.0.0.0", "8080");
$ws->onopen = function($client) {
  echo "New connection: " . $client->sockfd . "\n";
};
$ws->onclose = function($client) {
  echo "Closing connection: " . $client->sockfd . "\n";
};
$ws->onmessage = function($client, $msg) {
  echo "Received message from client (" . $client->sockfd . "): " . $msg->payload . "\n";
  echo "Sending it back...\n";
  $client->sendText($msg->payload);
};
$ws->run();
?>