pascaldevink/cloudevents

PHP implementation of the CloudEvents specificion (https://cloudevents.io/)

0.2 2020-03-28 19:59 UTC

This package is auto-updated.

Last update: 2024-10-29 05:10:49 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

PHP Implementation of CloudEvents. Supports version 0.3 of the specification.

Install

Via Composer

$ composer require pascaldevink/cloudevents

Usage

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

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Credits

License

The MIT License (MIT). Please see License File for more information.