lack / subscription
Manage subscriptions accross microservices
v1.3.2
2026-11-17 11:27 UTC
Requires
- php: >=8.0
- phore/http-client: *
- phore/hydrator: ^1.3.0
Requires (Dev)
- brace/core: *
- phore/filesystem: *
- phpspec/phpspec: ^7.6 || ^8.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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; }
In Routes (as Middleware)
AppLoader::extend(function (BraceApp $app) { $mount = CONF_API_MOUNT; $subscriptionAuthValidatorMw = new SubscriptionBasicAuthValidationMiddleware(); // Validate auth token from mailbox of subscription $app->router->registerClass($mount, DocFusionApiCtrl::class, [$subscriptionAuthValidatorMw]);
Unit tests
Install development dependencies with composer install, then run the PHPSpec suite:
composer test
Specifications live in spec/ and use the fixtures in cfg/.
GitHub Actions runs the suite on PHP 8.0 and 8.5, resolving dependencies separately
for each version (PHPSpec 7 on PHP 8.0 and PHPSpec 8 on PHP 8.5).