Symfony Web Socket Bundle

Installs: 748 584

Dependents: 9

Suggesters: 0

Stars: 508

Watchers: 29

Forks: 135

Open Issues: 81


v1.9.0-rc4 2019-06-15 20:31 UTC


Gitter Latest Stable Version Latest Unstable Version Total Downloads License Build Status Scrutinizer Code Quality Websocket


Gos Web Socket is a Symfony Bundle designed to bring together WebSocket functionality in a easy to use application architecture.

Much like Socket.IO it provides both server side and client side code ensuring you have to write as little as possible to get your app up and running.

Powered By Ratchet and Autobahn JS, with Symfony

Demo project

What can I do with this bundle

Make real time application like

  • Chat Application
  • Real time notification
  • Browser games

More commonly, all application who meet real time.

Built in feature

  • PHP Websocket server (IO / WAMP)
  • PHP Websocket client (IO / WAMP)
  • JS Websocket client (IO / WAMP)
  • PubSub (with routing)
  • Remote procedure call
  • User authentication through websocket
  • Periodic call
  • Origin checker
  • Push (zmq, amqp)


Code Cookbook


You must achieve these following steps before send your first message through websocket.

  1. Install the bundle
  2. Create you first topic handler
  3. Implement the client (Javascript)

Let's do it !

Installation Instructions

Step 1: Install via composer

composer require gos/web-socket-bundle

Step 2: Add to your App Kernel

// app/AppKernel.php

public function registerBundles()
    $bundles = array(
        // ...
        new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
        new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),

Step 3: Configure WebSocket Server

Add the following to your app/config.yml

# Web Socket Configuration
        port: 8080        #The port the socket server will listen on
        host:   #The host ip to bind to

Note: when connecting on the client, if possible use the same values as here to ensure compatibility for sessions etc.

Step 4: Launching the Server

The Server Side WebSocket installation is now complete. You should be able to run this from the root of your symfony installation.

For Symfony 2.7 & 2.8

php app/console gos:websocket:server

For Symfony >3.x

php bin/console gos:websocket:server

If everything is successful, you will see something similar to the following:

Starting Gos WebSocket
Launching Ratchet WS Server on:

This means the websocket server is now up and running !

From here, only the websocket server is running ! That doesn't mean you can subscribe, publish, call. Follow next step to do it :)

Next Steps

For further documentations on how to use WebSocket, please continue with the client side setup.

Original Project