firehed / cbor
CBOR decoder
Installs: 6 856
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 1
Requires (Dev)
- phpunit/phpunit: ^8.1
Suggests
- ext-bcmath: Enables parsing of very large values
This package is auto-updated.
Last update: 2024-11-08 01:42:26 UTC
README
Tools for working with the CBOR data format in PHP
Installation
composer require firehed/cbor
Usage
Note: Only decoding is supporing at this time
Decoding
$decoder = new Firehed\CBOR\Decoder(); $binaryString = "\x18\x64"; // CBOR for int(100) $data = $decoder->decode($binaryString); // OR $byteArray = [24, 100]; $data = $decoder->decodeArrayOfBytes($byteArray);
There is currently very limited support for tagged types.
When an unsupported tag is encountered, an OutOfBoundsException
will be thrown.
Tagged type support
- 0 DateTime as string
- 1 DateTime as epoch
- 2 Positive Bignum (returns as string, requires
bcmath
) - 3 Negative Bignum (same)
- 4 Decimal fraction
- 5 Bigfloat
- 21 base64url string
- 22 base64 string
- 23 base16 string
- 24 CBOR
- 32 URI
- 33 base64url
- 34 base64
- 35 regexp
- 36 MIME message
- 55799 Self-describing CBOR