PHP code example of novvor / central-sdk-php

1. Go to this page and download the library: Download novvor/central-sdk-php 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/ */

    

novvor / central-sdk-php example snippets


use Novvor\CentralSdk\CentralClientFactory;
use Novvor\CentralSdk\CentralConfiguration;

$central = CentralClientFactory::create(new CentralConfiguration(
    baseUrl: config('services.novvor_central.url'),
    issuer: config('services.novvor_central.issuer'),
    appId: config('services.novvor_central.app_id'),
    appKey: config('services.novvor_central.app_key'),
    snapshotVerificationKey: config('services.novvor_central.entitlement_snapshot_key'),
));

use Novvor\CentralSdk\CentralEnvironmentTemplate;

$template = new CentralEnvironmentTemplate(
    baseUrl: 'https://central.example.com',
    issuer: 'https://central.example.com',
    appId: 'my_application',
);

// Copy this output into an environment template or deployment configuration.
// It contains public values only.
echo $template->toDotenv();

$entitlement = $central->tenantEntitlement(
    tenantPublicId: $tenant->public_id,
    correlationId: $request->header('X-Correlation-ID'),
);

if (! $entitlement->isUsableAt()) {
    abort(403, 'This workspace is not licensed for the application.');
}

$snapshot = $central->tenantEntitlementSnapshot(
    tenantId: (string) $tenant->id,
    correlationId: $request->header('X-Correlation-ID'),
);

$enabledModules = $snapshot->modules;
$limits = $snapshot->limits;

$context = $central->exchangeLaunchCode(
    code: $request->string('code')->toString(),
    correlationId: $request->header('X-Correlation-ID'),
);
bash
composer