1. Go to this page and download the library: Download cloudevents/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/ */
cloudevents / sdk-php example snippets
use CloudEvents\V1\CloudEvent;
use CloudEvents\V1\CloudEventImmutable;
// Immutable CloudEvent
$immutableEvent = new CloudEventImmutable(
'1n6bFxDMHZFChlI4TVI9tdzphB9',
'/examples/php-sdk',
'com.example.type',
['example' => 'first-event'],
'application/json'
);
// Mutable CloudEvent
$mutableEvent = new CloudEvent(
'1n6bFxDMHZFChlI4TVI9tdzphB9',
'/examples/php-sdk',
'com.example.type',
['example' => 'first-event'],
'application/json'
);
// Create immutable from mutable or via versa
$event = CloudEventImmutable::createFromInterface($mutableEvent);
$event = CloudEvent::createFromInterface($immutableEvent);