PHPackages                             northwestern-sysdev/event-hub-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. northwestern-sysdev/event-hub-php-sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

northwestern-sysdev/event-hub-php-sdk
=====================================

PHP SDK for the Northwestern EventHub

v3.1.0(1y ago)060.2k↑202.6%[1 PRs](https://github.com/NIT-Administrative-Systems/SysDev-EventHub-PHP-SDK/pulls)1MITPHPPHP &gt;=8.2CI passing

Since Oct 31Pushed 1y ago5 watchersCompare

[ Source](https://github.com/NIT-Administrative-Systems/SysDev-EventHub-PHP-SDK)[ Packagist](https://packagist.org/packages/northwestern-sysdev/event-hub-php-sdk)[ RSS](/packages/northwestern-sysdev-event-hub-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (9)Used By (1)

EventHub PHP SDK [![Build Status](https://github.com/NIT-Administrative-Systems/SysDev-EventHub-PHP-SDK/workflows/PHPUnit%20Tests/badge.svg)](https://github.com/NIT-Administrative-Systems/SysDev-EventHub-PHP-SDK/actions?query=workflow%3A%22PHPUnit+Tests%22) [![Latest Stable Version](https://camo.githubusercontent.com/ef52495f3dd1a72970b3adc6c29ab0fe764e584a9a78feb9fb3a2acc6ef1fdf2/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7274687765737465726e2d7379736465762f6576656e742d6875622d7068702d73646b2f762f737461626c65)](https://packagist.org/packages/northwestern-sysdev/event-hub-php-sdk) [![Total Downloads](https://camo.githubusercontent.com/7b4e7c4af12e3565681704be64f6ac6748f510ef5760bb4c2740c30e0e4c0c40/68747470733a2f2f706f7365722e707567782e6f72672f6e6f7274687765737465726e2d7379736465762f6576656e742d6875622d7068702d73646b2f646f776e6c6f616473)](https://packagist.org/packages/northwestern-sysdev/event-hub-php-sdk) [![Coverage Status](https://camo.githubusercontent.com/6283c1595e8647aa7199a36f8720fcedcf1769e4863da3dc4c98cec00f4e3f30/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4e49542d41646d696e6973747261746976652d53797374656d732f5379734465762d4576656e744875622d5048502d53444b2f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/NIT-Administrative-Systems/SysDev-EventHub-PHP-SDK?branch=main)
==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#eventhub-php-sdk----)

This is a set of PHP classes design to give you easy access to the new Northwestern EventHub &amp; AMQ.

As of writing, this PHP SDK implements methods for all EventHub API calls.

Installation
------------

[](#installation)

This package is available via composer:

```
composer require northwestern-sysdev/event-hub-php-sdk
```

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
--------

[](#examples)

Here are some quick examples for using this SDK. For more information about EventHub &amp; its capabilities, please see the documentation on the [Service Registry](https://apiserviceregistry.northwestern.edu/AMQ-Dashboard).

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

[](#consumers)

You can loop something like the below example code &amp; schedule it in cron to poll the queue for messages.

```
$message_api = new \Northwestern\SysDev\SOA\EventHub\Message('https://northwestern-dev.apigee.net', 'my api key', new GuzzleHttp\Client);
$topic_name = 'etsysdev.test.queue.name';

try {
    $message = $message_api->readOldest($topic_name); // returns a DeliveredMessage object

    // The ID is useful for moving messages & troubleshooting. The raw message will be a plain text representation, ideal for logging!
    log_stuff_in_my_database($message->getId(), $message->getRawMessage());

    // If you use JSON messages, this will be a PHP associative array. For XML, you'll need to getRawMessage() and parse it yourself.
    $body = $message->getMessage();
    update_my_database($body['some_unique_id_from_the_message'], $body['some_other_info']['a_field']);

    // Should be the last thing you do in your try block
    $message_api->acknowledgeOldest($topic_name);
} catch (\Exception $e) {
    // If we get an error before the acknowledgeOldest call, the message won't be ack'd & removed from the queue.
    // This gives you an opportunity to fix your stuff & try again!
}
```

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

[](#publishers)

```
$topic_api = new \Northwestern\SysDev\SOA\EventHub\Topic('https://northwestern-dev.apigee.net', 'my api key', new GuzzleHttp\Client);
$topic_name = 'etsysdev.test.queue.name';

// If you are sending JSON messages, you can build your messages as PHP associative arrays and send those.
$my_message = [
    'id' => 1,
    'important_enterprise_data' => 'Bananas float in water because they are less dense in comparison.',
    'crucial_security_info' => 'Bananas grow on plants that are officially considered an herb.',
];
$message_id = $eh->writeJsonMessage($topic_name, $my_message);

// For XML, you are responsible for building the string & sending the appropriate content type.
$my_message = 'The banana is actually classified as a berry.'; // but you're using an XML builder -- do whatever to cast to string
$message_id = $eh->writeMessage($topic_name, $my_message, 'application/xml');
```

### Managing Webhooks

[](#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 &amp; the config options, see the [EventHub Webhook documentation](https://apiserviceregistry.northwestern.edu/help/using-webhooks).

```
$webhook_api = new \Northwestern\SysDev\SOA\EventHub\Webhook('https://northwestern-dev.apigee.net', 'my api key', new GuzzleHttp\Client);
$topic_name = 'etsysdev.test.queue.name';

// Create a paused webhook
$details = $webhook_api->create($topic_name, [
    'topicName' => $topic_name,
    'endpoint' => 'https://my-app-dev.northwestern.edu/api/webhook/receive', // the URL in your application
    'contentType' => 'application/json', // desired format for delivered messages
    'active' => false, // start off paused, so no deliveries are made to your app
    'securityTypes' => ['NONE'], // what authentication method(s) need to be done to authenticate w/ your endpoint -- see the webhook documentation for more info
    'webhookSecurity' => [
        ['securityType' => 'NONE']
    ]
]);

// When you're ready, turn the webhook on:
$details = $webhook_api->unpause($topic_name);

// You can adjust any of your settings whenever you need to -- see the EventHub docs for more info
$details = $webhook_api->updateConfig($topic_name, [
    'endpoint' => 'https://my-app-dev.northwestern.edu/api/v2/webhooks',
]);

// Or remove the webhook entirely & go back to polling the queue
$webhook_api->delete($topic_name);
```

FAQs
----

[](#faqs)

### Why do I have to pass in a GuzzleHttp Client?

[](#why-do-i-have-to-pass-in-a-guzzlehttp-client)

I've split this package off from a [Laravel-specific one](https://github.com/NIT-Administrative-Systems/SysDev-laravel-soa), 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](http://docs.guzzlephp.org/en/stable/handlers-and-middleware.html), 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:

```
$client = \Northwestern\SysDev\SOA\EventHub\Guzzle\RetryClient::make();
$api = new \Northwestern\SysDev\SOA\EventHub\Webhook('https://northwestern-dev.apigee.net', 'my api key', $client);
```

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 &amp; adjust `createRetryHandler()` to better suit your needs.

### Do you have more documentation?

[](#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!

[](#i-need-help)

The I&amp;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 .

Contributing
------------

[](#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:

```
{
    // Add this section
    "repositories": [
        {
            "type": "path",
            "url": "/home/vagrant/code/SysDev-EventHub-PHP-SDK"
        }
    ],

    "require": {
        // Any branch that isn't named in a version format can be specified by prefixing
        // it with 'dev-', so this would install the 'my-feature' branch from a local copy of the package.
        "northwestern-sysdev/event-hub-php-sdk": "dev-my-feature"
    },
}
```

You can test the package by running `phpunit && ./vendor/bin/phpstan analyse --level 5 src/`.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance42

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 69.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~456 days

Recently: every ~559 days

Total

6

Last Release

475d ago

Major Versions

v1.0.2 → v2.0.02021-02-15

v2.0.0 → v3.0.02024-02-06

PHP version history (4 changes)v1.0.1PHP &gt;=7.1

v2.0.0PHP &gt;=7.4

v3.0.0PHP &gt;=8.0

v3.1.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d4678c8051de43c86bddf6aec2c570d07175ac1011296dd25b8e6e97a0af34b?d=identicon)[northwestern-sysdev](/maintainers/northwestern-sysdev)

---

Top Contributors

[![nie7321](https://avatars.githubusercontent.com/u/27235866?v=4)](https://github.com/nie7321 "nie7321 (23 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (5 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (3 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (2 commits)")

---

Tags

northwesternnorthwestern-universitynorthwesternnorthwestern university

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/northwestern-sysdev-event-hub-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/northwestern-sysdev-event-hub-php-sdk/health.svg)](https://phpackages.com/packages/northwestern-sysdev-event-hub-php-sdk)
```

###  Alternatives

[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
