eislambey / wsify
There is no license information available for the latest version (dev-master) of this package.
PHP client for wsify
dev-master
2019-08-12 13:26 UTC
Requires
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpstan/phpstan: ^0.11.12
- phpunit/phpunit: ^8.1
This package is auto-updated.
Last update: 2024-12-13 01:10:41 UTC
README
PHP Client for Wsify realtime messaging server.
What is Wsify?
Just a tiny, simple and realtime pub/sub messaging service
For more information please see official repo: https://github.com/alash3al/wsify
Installation
composer require eislambey/wsify
Examples
Publish a message to all subscribers
<?php $uri = 'http://localhost:4040/publish'; $publisher = new \Wsify\Publisher($uri); $publisher->publish('channel_name', 'a message to sent');
Send a message to an user
<?php $uri = 'http://localhost:4040/publish'; $publisher = new \Wsify\Publisher($uri); $publisher->publish('channel_name', 'a message to sent', ['user_key']);
Using webhooks
<?php $events = new \Wsify\Events(); $events->onConnect(function (object $payload){ // `$payload->action` and `$payload->key` available }); $events->onDisconnect(function (object $payload){ // `$payload->action` and `$payload->key` available }); $events->onSubscribe(function (object $payload){ // `$payload->action`, `$payload->channel` and `$payload->key` available }); $events->onUnsubscribe(function (object $payload){ // `$payload->action`, `$payload->channel` and `$payload->key` available }); $events->listen();
Test
WSIFY_PUBLISH_URL='http://localhost:4040/publish' composer test
License
The MIT License. See LICENSE