Download the PHP package voryx/thruway-bundle without Composer
On this page you can find all versions of the php package voryx/thruway-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package thruway-bundle
ThruwayBundle
This a Symfony Bundle for Thruway, which is a php implementation of WAMP (Web Application Messaging Protocol).
Note: This project is still undergoing a lot of changes, so the API will change.
Quick Start with Composer
Install the Thruway Bundle
$ composer require "voryx/thruway-bundle"
Update AppKernel.php (when using Symfony < 4)
Configuration
With Symfony 4 use a filename like:
If you are using the in-memory user provider, you'll need to add a to the security firewall and set the in_memory_user_provider
.
You can also tag services with thruway.resource
and any annotation will get picked up
Note: tagging a service as thruway.resource
will make it public.
Authentication with FOSUserBundle via WampCRA
Change the Password Encoder (tricky on existing sites) to master wamp challenge
set voryx_thruway.user_provider to "fos_user.user_provider"
The WAMP-CRA service is already configured, we just need to add a tag to it to have the bundle install it:
Custom Authorization Manager
You can set your own Authorization Manager in order to check if a user (identified by its authid) is allowed to publish | subscribe | call | register
Create your Authorization Manager service, extending RouterModuleClient and implementing RealmModuleInterface (see the Thruway doc for details)
Register your authorization manager service
Insert your service name in the voryx_thruway config
Restart the Thruway server; it will now check authorization upon publish | subscribe | call | register. Remember to catch error when you try to subscribe to a topic (or any other action) as it may now be denied and this will be returned as an error.
Usage
Register RPC
Call RPC
Subscribe
Publish
It uses Symfony Serializer, so it can serialize and deserialize Entities
Start the Thruway Process
You can start the default Thruway workers (router and client workers), without any additional configuration.
$ nohup php app/console thruway:process start &
By default, the router starts on ws://127.0.0.1:8080
Workers
The Thruway bundle will start up a separate process for the router and each defined worker. If you haven't defined any workers, all of the annotated calls and subscriptions will be started within the default
worker.
There are two main ways to break your application apart into multiple workers.
-
Use the
worker
property on theRegister
andSubscribe
annotations. The following RPC will be added to theposts
worker. - Use the
@Worker
annotation on the class. The following annotation will create a worker calledchat
that can have a max of 5 instances.
If a worker is shut down with anything other than SIGTERM
, it will automatically be restarted.
More Commands
To see a list of running processes (workers)
$ php app/console thruway:process status
Stop a process, i.e. default
$ php app/console thruway:process stop default
Start a process, i.e. default
$ php app/console thruway:process start default
Javascript Client
For the client, you can use AutobahnJS or any other WAMPv2 compatible client.
Here are some examples
Symfony 4 Quick Start
Create config/packages/my_project.yml with the following config:
Create the controller src/Controller/TestController.php
Test to see if the RPC has been configured correctly bin/console thruway:debug
For more debug info for the RPC we created: bin/console thruway:debug com.example.add
Start everything: bin/console thruway:process start
The RPC com.example.add
is now available to any WAMP client connected to ws://127.0.0.1:8081 on realm1.
All versions of thruway-bundle with dependencies
symfony/finder Version ^2.7|^3.0|^4.0
voryx/thruway Version ~0.5
symfony/serializer Version ^2.7|^3.0|^4.0
react/child-process Version ~0.4
symfony/event-dispatcher Version ^2.7|^3.0|^4.0
thruway/pawl-transport Version ^0.5.0