Gos Web Socket is a Symfony2 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 Symfony2
Make real time application like
- Chat Application
- Real time notification
- Browser games
More commonly, all application who meet real time.
- 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)
- Installation Instructions
- Client Setup
- Server Side of RPC
- PubSub Topic Handlers
- Periodic Services(functions to be run every x seconds with the IO loop.)
- Session Management & User authentication
- Server Events
- Configuration Reference
- Ship in production
- Performance Bench
- Push integration
- SSL configuration
You must achieve these following steps before send your first message through websocket.
- Install the bundle
- Create you first topic handler
- Implement the client (Javascript)
Let's do it !
composer require gos/web-socket-bundle
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),
);
}
Add the following to your app/config.yml
# Web Socket Configuration
gos_web_socket:
server:
port: 8080 #The port the socket server will listen on
host: 127.0.0.1 #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.
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: 127.0.0.1:8080
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 :)
For further documentations on how to use WebSocket, please continue with the client side setup.