2017 © Pedro Peláez
 

library phpwebsockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

image

warriorxk/phpwebsockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  • Monday, July 23, 2018
  • by WarriorXK
  • Repository
  • 1 Watchers
  • 8 Stars
  • 241 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 22 Versions
  • 87 % Grown

The README.md

PHPWebSockets

Code documented Master: Build Status Develop: Build Status, (*1)

A PHP library to accept and create websocket connections, we aim to be 100% compliant with the websocket RFC and use the Autobahn test suite to ensure so. Currently the server and the client are 100% compliant with the autobahn testsuite minus a few non-strict notices, the compression extension for websockets will be implemented later, (*2)

Server

For websocket servers a new \PHPWebSockets\Server instance should be created with a bind address and a port to listen on. For ease of use you can use the UpdatesWrapper class, this will trigger certain callables set on basic functions., (*3)

A basic websocket echo server would be:, (*4)

require_once __DIR__ . '/vendor/autoload.php';

$wrapper = new \PHPWebSockets\UpdatesWrapper();
$wrapper->setMessageHandler(function(\PHPWebSockets\AConnection $connection, string $message, int $opcode) {

    echo 'Got message with length ' . strlen($message) . PHP_EOL;
    $connection->write($message, $opcode);

});


$server = new \PHPWebSockets\Server('tcp://0.0.0.0:9001');

while (TRUE) {
    $wrapper->update(0.1, $server->getConnections(TRUE));
}

If more control is required you can manually call $server->update(0.1); instead of using the wrapper, this will yield update objects which can be responded to., (*5)

Client

For connecting to a server the \PHPWebSockets\Client class should be constructed and the method connect($address, $port, $path) should be used to connect. For ease of use you can again use the UpdatesWrapper class or use $server->update(0.1); for better control., (*6)

A basic websocket echo client would be:, (*7)

require_once __DIR__ . '/../vendor/autoload.php';

$wrapper = new \PHPWebSockets\UpdatesWrapper();
$wrapper->setMessageHandler(function(\PHPWebSockets\AConnection $connection, string $message, int $opcode) {

    echo 'Got message with length ' . strlen($message) . PHP_EOL;
    $connection->write($message, $opcode);

});


$client = new \PHPWebSockets\Client();
if (!$client->connect('tcp://localhost:9001/webSocket')) {
    die('Unable to connect to server: ' . $client->getLastError() . PHP_EOL);
}

while (TRUE) {
    $wrapper->update(0.1, [$client]);
}

The Versions

23/07 2018

dev-master

9999999-dev https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

 

The Development Requires

php server client websocket socket ipc phpwebsockets

23/07 2018

2.1.0

2.1.0.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

 

The Development Requires

php server client websocket socket ipc phpwebsockets

23/07 2018

dev-develop

dev-develop https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

 

The Development Requires

php server client websocket socket ipc phpwebsockets

23/07 2018

dev-release/2.1.0

dev-release/2.1.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

 

The Development Requires

php server client websocket socket ipc phpwebsockets

06/04 2018

0.1.0

0.1.0.0

  Sources   Download

06/04 2018

1.0.0

1.0.0.0

  Sources   Download

06/04 2018

1.1.0

1.1.0.0

  Sources   Download

06/04 2018

1.2.0

1.2.0.0

  Sources   Download

06/04 2018

1.2.1

1.2.1.0

  Sources   Download

11/03 2018

dev-feature/Wrappers

dev-feature/Wrappers https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

 

The Development Requires

php server client websocket socket ipc phpwebsockets

02/11 2017

2.0.1

2.0.1.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

 

The Development Requires

php server client websocket socket ipc phpwebsockets

02/11 2017

dev-hotfix/2.0.1

dev-hotfix/2.0.1 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

 

The Development Requires

php server client websocket socket ipc phpwebsockets

03/07 2017

2.0.0

2.0.0.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

 

The Development Requires

php server client websocket socket ipc phpwebsockets

19/05 2017

dev-feature/Extensions

dev-feature/Extensions https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets

04/05 2017

1.8.1

1.8.1.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets

12/04 2017

1.8.0

1.8.0.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets

09/02 2017

1.7.0

1.7.0.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets

02/02 2017

1.6.0

1.6.0.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets

19/01 2017

1.5.0

1.5.0.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets

16/12 2016

1.4.0

1.4.0.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets

02/12 2016

1.3.1

1.3.1.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets

02/12 2016

1.3.0

1.3.0.0 https://github.com/WarriorXK/PHPWebSockets

A websocket library for PHP 7.0+ with support for IPC using socket pairs

  Sources   Download

MIT

The Requires

  • php >=7.0.0
  • ext-sockets *

 

php server client websocket socket ipc phpwebsockets