定制 2tvenom/cborencode 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

2tvenom/cborencode

最新稳定版本:1.0.2

Composer 安装命令:

composer require 2tvenom/cborencode

包简介

CBOR encoder for PHP

关键字:

README 文档

README

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.

统计信息

  • 总下载量: 12.41M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 62
  • 点击次数: 3
  • 依赖项目数: 17
  • 推荐数: 1

GitHub 信息

  • Stars: 62
  • Watchers: 7
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: PHP
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固