PHPackages                             p2/ratchet-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. p2/ratchet-bundle

ActiveLibrary[HTTP &amp; Networking](/categories/http)

p2/ratchet-bundle
=================

Symfony WebSocket bundle using the Ratchet WebSocket library

1.0.4(12y ago)265.8k15[6 issues](https://github.com/phillies2k/ratchet-bundle/issues)[3 PRs](https://github.com/phillies2k/ratchet-bundle/pulls)MITPHP

Since Jul 23Pushed 7y ago10 watchersCompare

[ Source](https://github.com/phillies2k/ratchet-bundle)[ Packagist](https://packagist.org/packages/p2/ratchet-bundle)[ Docs](https://github.com/phillies2k/ratchet-bundle)[ RSS](/packages/p2-ratchet-bundle/feed)WikiDiscussions develop Synced yesterday

READMEChangelogDependencies (7)Versions (7)Used By (0)

P2RatchetBundle
===============

[](#p2ratchetbundle)

Version: **1.0.6**

### Installation

[](#installation)

```
"require": {
    "p2/ratchet-bundle": "dev-master"
}

```

### Configuration

[](#configuration)

```
p2_ratchet:
    provider: ~             # The client provider to use, null for default
    address: 0.0.0.0        # The address to receive sockets on (0.0.0.0 means receive from any)
    port: 8080              # The port the socket server will listen on

```

### Usage

[](#usage)

- Implement the [ClientInterface](WebSocket/Client/ClientInterface.php) in your applications user model or document.
- Implement the [ClientProviderInterface](WebSocket/Client/ClientProviderInterface.php) in your applications user provider or managing repository.
- Set the `provider` setting to the service id of your applications client provider implementation or leave blank for the default anonymous provider.
- Implement the [ApplicationInterface](WebSocket/Server/ApplicationInterface.php) to listen on your own socket events ([Getting started](#getting-started)).
- Use the `{{ websocket_client(token, debug) }}` macro within your templates to enable the frontend websocket client.
- Write your client side event handler scripts. See the [Javascript API](#javascript-api) section for more detail.
- Open a terminal and start the server `app/console socket:server:start`. By default it will accept connection from \*:8080 (see [Command Line Tool](#command-line-tool))

### Getting started

[](#getting-started)

The [ApplicationInterface](WebSocket/Server/ApplicationInterface.php) acts only as an alias for symfony`s EventSubscriberInterface. Its used to detect websocket event subscribers explicitly.

Write your application as you would write a common event subscriber. The event handler methods will receive exactly one argument: a [ConnectionEvent](WebSocket/ConnectionEvent.php) instance, containing information about the socket connection and the payload (see [ConnectionInterface](WebSocket/Connection/ConnectionInterface.php) and [Payload](WebSocket/Payload.php) for more details).

```
# src/Acme/Bundle/ChatBundle/WebSocket/Application.php
