gekkone/nbt
Composer 安装命令:
composer require gekkone/nbt
包简介
Parser/Writer for the NBT file format
README 文档
README
This is a Named Binary Tag parser based upon the specification by Markus Persson.
From the spec: "NBT (Named Binary Tag) is a tag based binary format designed to carry large amounts of binary data with smaller amounts of additional data. An NBT file consists of a single GZIPped Named Tag of type TAG_Compound."
NBT data is also used in region files, which store the data for Minecraft worlds.
Requires the GMP Extension for PHP on 32-bit builds.
Installing
Composer
The library can be pulled in using composer; add the following to your composer.json:
{
"require": {
"gekkone/nbt": "~4.1"
}
}
Usage
Reading in from files, resources, or strings:
$nbtService = new \Nbt\Service(new \Nbt\DataHandler()); $tree = $nbtService->loadFile('filename.nbt'); $tree = $nbtService->readFilePointer($fPtr); $tree = $nbtService->readString($nbtString);
Then writing to a file, a resource, or returning a string:
$nbtService->writeFile('filename.nbt', $tree); $nbtService->writeFilePointer($fPtr, $tree); $nbtString = $nbtService->writeString($tree);
To look through a tree:
echo $tree->getName(); $type = $tree->getType(); // Value isn't set for Lists and Compounds; those nodes have children instead $value = $tree->getValue(); $sectionsNode = $tree->findChildByName('Sections');
To update a tree:
$node->setName('Name'); $node->setValue(123456);
To create new nodes:
// This is pretty useless on it's own really $node = \Nbt\Tag::tagByte('aByte', 0x0f); // You'll be building trees with Compounds and Lists mostly; both take an array of nodes as their values $tree = \Nbt\Tag::tagCompound('aCompound', [ \Nbt\Tag::tagByte('aByte', 0x0f), \Nbt\Tag::tagInt('aNumber', 12345), ]); // Child tags for lists do not require names, as they are not named - and they must match the payload of the list $tree = \Nbt\Tag::tagList('aList', \Nbt\Tag::TAG_STRING, [ \Nbt\Tag::tagString('', 'firstString'), \Nbt\Tag::tagString('', 'secondString'), ]);
History
The original PHP NBT package was written by TheFrozenFire.
This repo has been forked by many, but most forks have one of two issues; they either don't handle TAG_INT_ARRAY or don't correctly handle writing to a file pointer.
The returned format - an array - isn't ideal for creating your own NBT data, and some kind of wrapper was required to assist in creation.
I tidied up the code a little, then added nicmart/tree to store the NBT data; after much work, it's nothing like the original, so I've pulled it into it's own (non-forked) repo.
gekkone/nbt 适用场景与选型建议
gekkone/nbt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 10 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「encode」 「decode」 「binary」 「NBT」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gekkone/nbt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gekkone/nbt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gekkone/nbt 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.
Encode integer IDs using a preset or customized symbol set
Runn Me! Serialization Library
A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.
With the JSON codec you will be able to encode into and decode from JSON data in an object oriented way. It wraps PHP's functions `json_encode()` and `json_decode()`.
Microweber security scanner is a php antimalware/antivirus scanner script written in php for scan your project.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-10