dasprid / cbor
This package is abandoned and no longer maintained.
No replacement package was suggested.
A PHP implementation of Concise Binary Object Representation (CBOR)
1.0.0
2018-10-15 14:03 UTC
Requires
- php: ^7.2
- brick/math: ^0.8
- dasprid/enum: ^1.0
Requires (Dev)
- ext-json: ^1.6
- phpunit/phpunit: ^7.4
- squizlabs/php_codesniffer: ^2.8
This package is auto-updated.
Last update: 2022-04-15 22:43:24 UTC
README
A PHP implementation of RFC 7049: Concise Binary Object Representation (CBOR)
Features
- Encodes and decodes all examples described in RFC 7049
- Provides a fluent interface builder for CBOR messages
- Supports semantic tags
- Supports 64bit integer values
Usage
Encoding Example
<?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);
Decoding Example
<?php $dataItems = \DASPRiD\Cbor\CborDecoder::decodeString($encodedBytes); foreach ($dataItems as $dataItem) { // Process data item }