Download the PHP package hannesvdvreken/socketio without Composer
On this page you can find all versions of the php package hannesvdvreken/socketio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hannesvdvreken/socketio
More information about hannesvdvreken/socketio
Files in hannesvdvreken/socketio
Package socketio
Short Description Pushing Socket.io messages to Redis for socket.io's Redis socket manager.
License MIT
Informations about the package socketio
Socket.io messages from PHP
What does it do?
This package allows you to transfer socket message to a Node.js process via Redis. Socket.io has a [redis adapter]() to allow scaling a Node.js cluster to send socket messages to any client connected to any process. We can use this to send messages straight from PHP.
This package provides a Socketio\Socketio
class with similar methods as the socket.io server in Node.js such as
emit
, in
, to
, of
and adapter
.
Usage
First we can create a Socketio\Socketio
object.
It has some of the same methods as in Node.js:
Namespace
Setup a server object with a different namespace. The $io
object keeps the same namespace.
Or use a callback:
Rooms
Send to specific room(s):
Where in
is an alias of to
. You can send to several rooms at the same time by chaining to
calls.
The rooms are reset after every emit
call. This is similar behaviour as in Node.js.
Adapters
By default, the Socketio\Socketio
object configures a Memory
adapter.
This adapter fakes socket message delivery and can be useful for testing/stubbing.
To setup the Redis
adapter you need to configure some dependencies first.
If you have ext-msgpack
installed, the Socketio\Utils\Msgpack will use the native
msgpack_pack
and msgpack_unpack
methods which are supposed to be the fastest around.
If not, you can pass it Msgpack\Encoder
and Msgpack\Decoder
objects to do the encoding/decoding.
These come pre-installed with composer if you require this package.
The Node.js process
Right now, you're good to go!
Contributing
Stick to PSR-2 Coding Standards and be nice in communication.
License
MIT