PHP code example of pascaldevink / cloudevents
1. Go to this page and download the library: Download pascaldevink/cloudevents 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/ */
pascaldevink / cloudevents example snippets
php
$cloudEvent = new \PascalDeVink\CloudEvents\V03\CloudEvent(
new EventId('89328232-6202-4758-8050-C9E4690431CA'),
new Source(Uri::createFromString('github://pull')),
new EventType('com.github.pull.create'),
new SchemaUrl(Uri::createFromString('http://github.com/schema/pull')),
new Subject('1234'),
new EventTime(new DateTimeImmutable('2018-08-09T21:55:16+00:00')),
null,
JsonData::fromArray([])
);
$formatter = new \PascalDeVink\Format\JsonFormatter();
$jsonCloudEvent = $formatter->encode($cloudEvent);
echo $jsonCloudEvent;
$newCloudEvent = $formatter->decode($jsonCloudEvent);