PHP code example of lack / subscription

1. Go to this page and download the library: Download lack/subscription library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lack / subscription example snippets



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

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


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

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]);