A simple PHP WebSocket implementation for PHP 7.1
A simple websocket server and client package for PHP 7.1.
The library is PSR-4 compatible, with a vendor name of Wrench. It's available on Composer as wrench/wrench, so you
can:
composer require wrench/wrench ~3.0This creates a server on 127.0.0.1:8000 with one Application that listens for
WebSocket requests to ws://localhost:8000/echo and ws://localhost:8000/chat:
…/**
* A client side example, that sends a string and will receive the data back to the connection that sent it
*/
$client = new Client('ws://localhost:8000, http://localhost:8000);
$client->connect();
$client->sendData('hello');
$response = $client->receive()[0]->getPayload();
$client->disconnect();See the CHANGELOG for detailed information about changes between releases.
The latest major release dropped support for PHP versions prior to 7.1. If you need support for older versions of PHP, see the 2.0 branch. The latest 2.0 branch release is 2.0.8. You can install it with:
composer require wrench/wrench ~2.0./vendor/bin/phpcs and fix any errors that you come across./vendor/bin/phpunit --exclude-group large,medium for a fast test between changesNo open issues yet, or sync has not completed.