2017 © Pedro Peláez
 

library ratchet

PHP WebSocket library

image

gos/ratchet

PHP WebSocket library

  • Tuesday, December 12, 2017
  • by ProPheT777
  • Repository
  • 4 Watchers
  • 5 Stars
  • 203,311 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 509 Forks
  • 0 Open issues
  • 29 Versions
  • 21 % Grown

The README.md

Ratchet for Gos

Build Status Latest Stable Version, (*1)

A PHP 5.3 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)

WebSocket Compliance

  • Supports the RFC6455, HyBi-10+, and Hixie76 protocol versions (at the same time)
  • Tested on Chrome 13+, Firefox 6+, Safari 5+, iOS 4.2+, IE 8+
  • Ratchet passes the Autobahn Testsuite (non-binary messages)

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., (*3)

PHP 5.3.9 (or higher) is required. If you have access, PHP 5.4 (or higher) is highly recommended for its performance improvements., (*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);
    $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.send('Hello Me!');

The Versions

12/12 2017

dev-master

9999999-dev http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

12/12 2017
03/03 2016

v0.3.5

0.3.5.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

02/08 2015

v0.3.4

0.3.4.0 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

15/07 2015

dev-handshake-fix

dev-handshake-fix http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

31/05 2015

dev-0.4-wip/psr7

dev-0.4-wip/psr7 http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server websocket 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

17/05 2015

dev-0.4-wip/comp-interfaces

dev-0.4-wip/comp-interfaces http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

06/09 2014

dev-rfc-split

dev-rfc-split http://socketo.me

PHP WebSocket library

  Sources   Download

MIT

The Requires

 

server sockets ratchet websockets

08/06 2014

0.4.x-dev

0.4.9999999.9999999-dev 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