Download the PHP package northwestern-sysdev/event-hub-php-sdk without Composer
On this page you can find all versions of the php package northwestern-sysdev/event-hub-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download northwestern-sysdev/event-hub-php-sdk
More information about northwestern-sysdev/event-hub-php-sdk
Files in northwestern-sysdev/event-hub-php-sdk
Package event-hub-php-sdk
Short Description PHP SDK for the Northwestern EventHub
License MIT
Informations about the package event-hub-php-sdk
EventHub PHP SDK
This is a set of PHP classes design to give you easy access to the new Northwestern EventHub & AMQ.
As of writing, this PHP SDK implements methods for all EventHub API calls.
Installation
This package is available via composer:
The latest version of this package supports PHP v7.4+. It may not work on older versions of PHP. Please use v1 if you require compatability with older versions!
Examples
Here are some quick examples for using this SDK. For more information about EventHub & its capabilities, please see the documentation on the Service Registry.
Note that all methods from this SDK can throw Northwestern\SysDev\SOA\EventHub\Exception\EventHubDown
and Northwestern\SysDev\SOA\EventHub\Exception\EventHubError
messages. The former indicates a network problem or outage; the latter is something wrong with your usage of EventHub.
Consumers
You can loop something like the below example code & schedule it in cron to poll the queue for messages.
Just be aware that EventHub supports webhook delivery; it can do HTTP POSTs to your application when it receives messages in real-time. You should evaluate that option before implementing queue polling.
Publishers
Managing Webhooks
EventHub can be configured to deliver messages destined for your application via HTTP POSTs to an API endpoint you've created via webhooks. This is a self-service feature you can configure yourself.
For full details on how this works & the config options, see the EventHub Webhook documentation.
FAQs
Why do I have to pass in a GuzzleHttp Client?
I've split this package off from a Laravel-specific one, and having Guzzle in the constructor makes it easy for me to let Laravel's service container inject the dependency.
Guzzle supports some cool middleware stuff, which you may want to set up before giving it to the EventHub SDK.
In fact, this package comes with a re-try middleware for temporary network errors. You can do this instead to get a Guzzle Client that will make three immediate re-try attempts if it's unable to establish a connection to EventHub:
This won't auto-retry anything that gets an HTTP error code, e.g. 401 Unauthorized
won't trigger a re-try attempt. Feel free to extend the class & adjust createRetryHandler()
to better suit your needs.
Do you have more documentation?
Not really. There are PHP docblocks in the code, but they just refer you back to the main EventHub API documentation. This SDK is just a little adapter layer to make using EventHub feel more PHP-y.
I need help!
The I&A team is the primary contact for EventHub -- I'm an end-user too!
But, if you have questions specifically abou the PHP SDK, you can ask in #et-sysdev
on the NIT Slack or email [email protected].
Contributing
Submit a pull request!
If you need to include a local copy of the package for development purposes, adjust your consuming apps' composer.json
thusly:
You can test the package by running phpunit && ./vendor/bin/phpstan analyse --level 5 src/
.