Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cborencode Laravel Package

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.

View on GitHub
Deep Wiki
Context7

#CBOR encoder for PHP

Decoder/encoder from PHP data to CBOR binary string. This code has been developed and maintained by Ven at January 2014.

CBOR is an object representation format defined by the IETF. The specification has recently been approved as an IETF Standards-Track specification and has been published as RFC 7049.

Installation

Add 2tvenom/cborencode as a requirement to composer.json:

{
    "require": {
       "2tvenom/cborencode": "1.0.0"
    }
}

Usage

<?php
include("vendor/autoload.php");

//target for encode
$target = array(true, array("variable1" => 100000, "variable2" => "Hello, World!", "Hello!"), 0.234, 0, null, 590834290589032580);

//encoded string
$encoded_data = \CBOR\CBOREncoder::encode($target);

//debug info output
$byte_arr = unpack("C*", $encoded_data);

echo "Byte hex map = " . implode(" ", array_map(function($byte){
        return "0x" . strtoupper(dechex($byte));
    }, $byte_arr)) . PHP_EOL;

echo "Byte dec map = " . implode(" ", $byte_arr) . PHP_EOL;

//decode
$decoded_variable = \CBOR\CBOREncoder::decode($encoded_data);
//output
var_dump($decoded_variable);

Compatibility

Checked with Ruby extension in encode and decode

Known issues

  • Not support tags. 6 major type (in future)
  • Not support 16 and 32 floats encoding (maybe in future)
  • All floats will be serialized only as IEEE 754 Double-Precision Float (64 bits follow)
  • Encode does't support indefinite-length values.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4