Download the PHP package gamma/pushpin-bundle without Composer
On this page you can find all versions of the php package gamma/pushpin-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gamma/pushpin-bundle
More information about gamma/pushpin-bundle
Files in gamma/pushpin-bundle
Package pushpin-bundle
Short Description Pushpin proxy integration for Symfony applications
License MIT
Informations about the package pushpin-bundle
GammaPushpinBundle
Symfony Bundle that helps you to add a realtime features to your applications using Pushpin reverse proxy. Integrates php-gripcontrol library.
Features
- Works with WebSocket-over-HTTP Requests from Pushpin
- De serializes (using jms/serializer) a TEXT events from Pushpin into DTOs (events) specified by your configuration
- Handling WebSocketEvent with your specific handler
- Pushpin helpers to publishing to a channel, subscribing, detaching etc.
Installation
Install a bundle
composer require "gamma/pushpin-bundle"
Register the bundle in app/AppKernel.php
:
Configuration
For testing you need to install a Pushpin on dev machine. And enable WebSocket-over-HTTP in config file:
Usage
Create an event class. Extend . This class will hold a data from websocket clients:
Update configuration with your new event:
Create handler service for your event by extending class: ` Here you can return a single WebSocketEvent, array of WebSocketEvent objects or WebSocketEventsDTO that holds events as array as well. Register handler as a Symfony service:
Note: Here is should be similar to logical name of event in configuration.
In a Controller this Events should be passed to function. So last thing you need to do is to create a simple controller that Pushpin will access.
If everything is ok you should be able to connect to Pushpin's websocket port (7999 by default) with URL:
ws://localhost:7999/websocket/chat
You can test with wscat utility:
Now clients can send a message to your application:
This will call your handler and return a result back to a client.
Working with channels
Pushpin works as a publish-subscribe service. So you have ability to subscribe clients to a specific channels and publish a messages to it. Anything that can be a channel in your application should implement a with one method . To publish messages you can also use
By calling methods on you can:
- subscribe client to a channel
- publish to a channel
- unsubscribe from channel
- detach connection
Here is additional info on Pushpin
Example of working application
TODO
- HTTP streaming with Pushpin
- more documentation
- more
All versions of pushpin-bundle with dependencies
fanout/gripcontrol Version ^2.0
symfony/framework-bundle Version ~2.3|~3.4
jms/serializer Version ^1.1@dev
sensio/framework-extra-bundle Version ^5.1