Download the PHP package cucumber/messages without Composer
On this page you can find all versions of the php package cucumber/messages. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cucumber/messages
More information about cucumber/messages
Files in cucumber/messages
Package messages
Short Description JSON schema-based messages for Cucumber's inter-process communication
License MIT
Informations about the package messages
Cucumber Messages
This is a PHP implementation of the Cucumber Messages protocol
Requirements
- PHP 8.1
- Ext-JSON
Installation
Install using composer.
Usage
Consuming messages
Cucumber Messages are contained in a top-level Envelope object when serialised. Members are exposed via public readonly properties. Because many properties are nullable, it may be convenient to use the nullsafe operator to access them:
Decoding JSON strings
You can construct an Envelope from a JSON string:
Handling NDJSON Streams
Cucumber Messages are streamed as Newline Delimited JSON (NDJSON).
You can use the NdJsonStreamReader
to obtain a Generator that produces Envelopes. It's important to remember that any
decoding errors will be thrown as the generator is consumed, not when it's returned.
Producing messages
All arguments of a Cucumber Message are optional, but any non-nullable fields will have default values.
Because Messages tend to have a large number of arguments, it's recommended to use named fields to construct them:
Encoding a JSON string
An Envelope can be encoded as a JSON string:
Do not json_encode()
the object externally, as the correct encoding options may not be set.
Producing JSON streams
Cucumber Messages are streamed as Newline Delimited JSON (NDJSON).
You can use the NdJsonStreamReader to write the contents of list of Envelopes to a stream.
All versions of messages with dependencies
ext-json Version *