This package is a plug to work with Pusher for FEAST Framework
Recommended installation uses composer. This allows for quick setup.
Run composer install feast/pusher
.
In container.php
, add the following at the bottom of the file.
$container->add(\FeastFramework\Pusher\Pusher::class,new \FeastFramework\Pusher\Pusher());
Alternatively, if you do not wish to use composer, this plugin can be manually installed by downloading and placed in a
folder of your choosing if you do not wish to use composer. You will need to add a path mapping in container.php
before adding Pusher to the container. Replace src
in the block below with the path to your installation of the Pusher
plugin.
/** @var \Feast\Autoloader $autoLoader */
$autoLoader->addPathMapping('FeastFramework\\Pusher', ['src']);
$container->add(\FeastFramework\Pusher\Pusher::class,new \FeastFramework\Pusher\Pusher());
The Pusher plugin is configured by adding an array into your configs/config.php
that contains the necessary keys. See
sample below. Note that if you name your configuration namespace pusher
, then you do not need to pass it in to the
various methods.
$environment['production'] = ['
pusher' => [
'cluster' => 'us2',
'key' => 'Your-App-Key',
'secret' => 'Your-Secret-Key',
'appid' => 'App-ID'
]
];
The Pusher plugin can be automatically injected into both controllers and plugin classes by type-hinting the
argument \FeastFramework\Pusher\Pusher
. To learn more about Dependency injection in FEAST, see the
docs, here
Alternatively, you may directly instantiate by calling new Pusher();
The Pusher object has the following methods. All methods take various parameters as well as an optional configuration
namespace. Methods return objects that represent the data from the pusher API. See the src/Response
folder for
details.
getUsers
- get user information for a channel- Parameters
channel
pusherConfigNamespace
- defaults topusher
- Parameters
event
- Trigger a single event.- Parameters
name
- The name of the event to trigger.data
- An array or stdClass of data to pass to the event.channels
- Either a single channel as a string, or an array of channels to publish to.socketId
- Exclude the event from the given socket id if passed in. Defaults to null.info
- An array of attributes which should be returned. Currently valid values are user_count and subscription_count.pusherConfigNamespace
- defaults topusher
- Parameters
batchEvents
- Trigger multiple events.- Parameters
eventData
- See the Pusher docs for more info.pusherConfigNamespace
- defaults topusher
- Parameters
channelInfo
- Fetch information for a single channel.- Parameters
channel
- Channel name to fetch information forinfoType
- An array of attributes to fetch. Valid options areuser_count
andsubscription_count
.pusherConfigNamespace
- defaults topusher
- Parameters
channelsInfo
- Fetch information for multiple channels- Parameters
prefix
- Filter returned values by specified prefix. Defaults to null.infoType
- An array of attributes to fetch. Valid option currently onlyuser_count
.pusherConfigNamespace
- defaults topusher
- Parameters