pascaldevink/cloudevents

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

0.1 2018-08-10 12:00 UTC

README

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

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

Install

Via Composer

$ composer require pascaldevink/cloudevents

Usage

$cloudEvent = new \PascalDeVink\CloudEvent(
    new EventType('com.github.pull.create', '1.0.0'),
    new CloudEventsVersion('0.1'),
    new Source(Uri::createFromString('github://pull')),
    new EventId('89328232-6202-4758-8050-C9E4690431CA'),
    new EventTime(new DateTimeImmutable('2018-08-09T21:55:16+00:00')),
    new SchemaUrl(Uri::createFromString('http://github.com/schema/pull')),
    JsonData::fromArray([])
);

$formatter = new \PascalDeVink\Format\JsonFormatter();
$formattedCloudEvent = $formatter->format($cloudEvent);

echo $formattedCloudEvent;

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.