2tvenom/cborencode
Laravel/PHP CBOR encoder for compact binary data serialization. Encode arrays and values into RFC 7049/8949-style CBOR for storage, caching, and APIs. Lightweight package focused on producing valid CBOR payloads with simple usage.
Install via Composer:
composer require 2tvenom/cborencode
Then, simply use the encoder in your code:
use CBOR\Encoder;
$payload = [
'device_id' => 'sensor-001',
'temperature' => 23.7,
'active' => true,
'timestamp' => time(),
];
$encoded = Encoder::encode($payload);
// $encoded is a binary string suitable for HTTP request body, MQTT message, etc.
Start with encoding simple associative arrays or objects — this mirrors real-world API request/response serialization needs.
string, int, float, bool, null, array, Traversable) before encoding.cbor.phar, phpcbor, or ext-cbor) for decoding. Double-check interoperability if decoding in other languages.float values with care; IEEE 754 double-precision may not match expectations in cross-platform scenarios — consider string encoding for high-precision numbers (e.g., financial data).[4, $timestamp] for epoch seconds) if required.CBOR\ — avoid conflicting classes or use autoloader aliases if integrating with other libraries.hash_file('sha256', $encoded)).How can I help you explore Laravel packages today?