lack/subscription

Manage subscriptions accross microservices

v1.2.2 2024-04-25 14:14 UTC

This package is auto-updated.

Last update: 2024-09-13 12:33:34 UTC


README

Library to manage subscriptions accross services

Installation

composer install lack/subscription

Adding to Brace App

01_di.php

$app->addModule(
    new SubscriptionClientModule(
        "file:///opt/conf/",
        CONF_SUBSCRIPTION_CLIENT_ID,
        CONF_SUBSCRIPTION_CLIENT_SECRET
    )
);

10_middleware.php

$app->setPipe([
    ...
    // Below RouterEvalMiddleware
    // Search for {subscription_id} in the route and load the subscription object
    new SubscriptionMiddleware(),
    ...
]);

Usage

In Controller Classes

The RouterEvalMiddleware will register a service subscription in the container. You can use this service to get the subscription object.

public function loadSubscription(T_Subscritpion $subscription)
{
    return $subscription;
}