A PHP implementation of RFC 7049: Concise Binary Object Representation (CBOR)
- Encodes and decodes all examples described in RFC 7049
- Provides a fluent interface builder for CBOR messages
- Supports semantic tags
- Supports 64bit integer values
<?php
$output = new \SplTempFileObject();
(new \DASPRiD\Cbor\CborEncoder($output))->encode((new \DASPRiD\Cbor\CborBuilder())
->add('text')
->add(1234)
->addByteString("\x10")
->addArray()
->add(1)
->add('text')
->end()
->build()
);
$length = $output->ftell();
$output->rewind();
$encodedBytes = $output->fread($length);
<?php
$dataItems = \DASPRiD\Cbor\CborDecoder::decodeString($encodedBytes);
foreach ($dataItems as $dataItem) {
// Process data item
}