定制 jaredclemence/binn 二次开发

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

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

jaredclemence/binn

Composer 安装命令:

composer require jaredclemence/binn

包简介

A PHP implementation of the BINN file format. The BINN format is a standardized format that is useful in sharing data between different systems (possibly coded in different languages). It handles file sizes up to 2GB.

README 文档

README

A PHP implementation of Binn formatted strings for standard communication of data.

The BINN Specification (visible here) is one of many standardized binary formats for data storage and transfer. It is useful for storing data in a way that can be read by any system, unlike the native PHP serialize method which is only natively readable by PHP itself. Many languages have BINN implementations already, which makes this extremely useful for communicating data-sets between different systems.

The specification linked above hints at using 2's compliment formatting for numbers. More research must be done to learn how dates should be formatted. This readme will be updated with current information as the library grows.

Binary representation is important for encryption and signing. The BINN format provides a deterministic method of ensuring that an object has the same exact binary representation before a cryptographic signature is verified or a hash is generated.

Main interface for working with BinnContainers.

For the most basic interactions and the quickest start, please use the class \JRC\binn\BinnSpecification(). This class provides a simple user interface for encoding BinnObjects and decoding them again.

In this implementation, any "Object" subtypes are always returned as a stdClass implementation with public attributes. All "List" and "Map" types are returned as arrays. Similarly, any array with a string index is written as an Object to conform with the Binn specification. Container types are always written with keys in alphabetical order. This is not part of a standard BinnSpecification, but it ensures that the byte order is always deterministic, which means that the binary output of these processes can be used for encryption and decryption without surprises. (An output can be verified against a signature, for example).

Due to limitations of the PHP language, some defaults have been selected for writing blindly (letting the system auto detect container subtypes). For example, PHP does not handle 64-bit decimals accurately, so this specification defaults to the FLOAT type over DOUBLES. Additionally, \DateTime objects are automatically set to the DATETIME subtype rather than the DATE or the TIME subtypes.

Future implementations will allow you to construct a container using specific subtypes and data.

Reading Binn Data

//1. Load binn data (received from sender or read from file) into a variable
$binnContainerString = "\xE2\x08\x01\x03one\x01"; //BINN data is a binary string

//2. Initialize the main interface 
$binnSpecification = new \JRC\binn\BinnSpecification();

//3. Call the write method.
$nativePHPdata = $binnSpecification->read( $binnContainerString );

//4. use output in code
var_dump( $nativePHPdata->one ); //outputs: true

Writing Binn Data

//1. Put data into a container class (array or object) with public attributes.
$a = new stdClass();
$a->one = 1;
$a->two = 2;
$a->three = new stdClass();
$a->three->cat = "cat";
$a->three->dog = "dog";

//2. Initialize the main interface 
$binnSpecification = new \JRC\binn\BinnSpecification();

//3. Call the write method.
$output = $binnSpecification->write( $a );

//4. Store output or transmit output to a recipient.

jaredclemence/binn 适用场景与选型建议

jaredclemence/binn 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jaredclemence/binn 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jaredclemence/binn 我们能提供哪些服务?
定制开发 / 二次开发

基于 jaredclemence/binn 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2018-07-09