2017 © Pedro Peláez
 

library ratchet

PHP WebSocket library

image

cboden/ratchet

PHP WebSocket library

  • Tuesday, March 6, 2018
  • by cboden
  • Repository
  • 230 Watchers
  • 4231 Stars
  • 2,138,251 Installations
  • PHP
  • 164 Dependents
  • 8 Suggesters
  • 506 Forks
  • 77 Open issues
  • 29 Versions
  • 7 % Grown

The README.md

Ratchet

[GitHub Actions][GA Link] Autobahn Testsuite Latest Stable Version, (*1)

A PHP library for asynchronously serving WebSockets. Build up your application through simple interfaces and re-use your application without changing any of its code just by combining different components., (*2)

Reviving Ratchet!

We're currently aiming to revive Ratchet to get it up to date with the latest versions and use this as a starting point for bigger updates to come. We need your help to achieve this goal, see ticket #1054 for ways to help out. ❤️, (*3)

Requirements

Shell access is required and root access is recommended. To avoid proxy/firewall blockage it's recommended WebSockets are requested on port 80 or 443 (SSL), which requires root access. In order to do this, along with your sync web stack, you can either use a reverse proxy or two separate machines. You can find more details in the server conf docs., (*4)

Documentation

User and API documentation is available on Ratchet's website: http://socketo.me, (*5)

See https://github.com/cboden/Ratchet-examples for some out-of-the-box working demos using Ratchet., (*6)

Need help? Have a question? Want to provide feedback? Write a message on the Google Groups Mailing List., (*7)


A quick example

<?php
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;

    // Make sure composer dependencies have been installed
    require __DIR__ . '/vendor/autoload.php';

/**
 * chat.php
 * Send any incoming messages to all connected clients (except sender)
 */
class MyChat implements MessageComponentInterface {
    protected $clients;

    public function __construct() {
        $this->clients = new \SplObjectStorage;
    }

    public function onOpen(ConnectionInterface $conn) {
        $this->clients->attach($conn);
    }

    public function onMessage(ConnectionInterface $from, $msg) {
        foreach ($this->clients as $client) {
            if ($from != $client) {
                $client->send($msg);
            }
        }
    }

    public function onClose(ConnectionInterface $conn) {
        $this->clients->detach($conn);
    }

    public function onError(ConnectionInterface $conn, \Exception $e) {
        $conn->close();
    }
}

    // Run the server application through the WebSocket protocol on port 8080
    $app = new Ratchet\App('localhost', 8080);
    $app->route('/chat', new MyChat, array('*'));
    $app->route('/echo', new Ratchet\Server\EchoServer, array('*'));
    $app->run();
$ php chat.php
    // Then some JavaScript in the browser:
    var conn = new WebSocket('ws://localhost:8080/echo');
    conn.onmessage = function(e) { console.log(e.data); };
    conn.onopen = function(e) { conn.send('Hello Me!'); };

The Versions

06/03 2018
12/12 2017

dev-fix-#516

dev-fix-#516 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

The Development Requires

server websocket sockets ratchet websockets

15/10 2017

dev-router-race-fix

dev-router-race-fix http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

The Development Requires

server websocket sockets ratchet websockets

14/09 2017
19/04 2017

0.4.x-dev

0.4.9999999.9999999-dev http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

The Development Requires

server websocket sockets ratchet websockets

06/01 2017

v0.3.6

0.3.6.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

25/05 2016

v0.3.5

0.3.5.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

23/12 2015

v0.3.4

0.3.4.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

27/05 2015

v0.3.3

0.3.3.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

08/06 2014

v0.3.2

0.3.2.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

27/05 2014

v0.3.1

0.3.1.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

14/10 2013

v0.3.0

0.3.0.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

20/09 2013

v0.2.8

0.2.8.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

26/07 2013

dev-wamp-sync-bug

dev-wamp-sync-bug http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

09/06 2013

v0.2.7

0.2.7.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

02/06 2013

v0.2.6

0.2.6.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

02/04 2013

v0.2.5

0.2.5.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

09/03 2013

v0.2.4

0.2.4.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

22/11 2012

v0.2.3

0.2.3.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

20/10 2012

v0.2.2

0.2.2.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

13/10 2012

v0.2.1

0.2.1.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

07/09 2012

v0.2.0

0.2.0.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

13/07 2012

v0.1.5

0.1.5.0

PHP WebSocket server component library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

18/06 2012

v0.1.4

0.1.4.0

PHP WebSocket server component library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

15/06 2012

v0.1.3

0.1.3.0

PHP WebSocket server component library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

19/05 2012

v0.1.2

0.1.2.0

PHP WebSocket server component library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

15/05 2012

0.1.1

0.1.1.0

PHP WebSocket server component library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

11/05 2012

v0.1

0.1.0.0

PHP WebSocket server component library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets