PHP code example of nubitio / platform

1. Go to this page and download the library: Download nubitio/platform 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/ */

    

nubitio / platform example snippets


use Nubit\Platform\Privacy\Attribute\SensitiveData;
use Nubit\Platform\Privacy\DataClassification;

final readonly class LoginContext
{
    public function __construct(
        public string $username,
        #[SensitiveData(DataClassification::Confidential)]
        public string $email,
        #[SensitiveData(DataClassification::Restricted)]
        public string $accessToken,
    ) {
    }
}

$context = [
    'email' => new SensitiveValue($email, DataClassification::Confidential),
    'token' => new SensitiveValue($token, DataClassification::Restricted),
];

// Safe: the structured value passes through the redactor.
$logger->info('Authentication failed', ['email' => new SensitiveValue(
    $email,
    DataClassification::Confidential,
)]);

$result = $publisher->publish(new AnalyticsEvent(
    id: $commandId, // stable idempotency key
    name: 'invoice.paid',
    schemaVersion: 1,
    purpose: AnalyticsPurpose::Operational,
    payload: new InvoicePaidAnalyticsPayload($channel, $customerEmail),
));