{"id":17189625,"url":"https://github.com/rickselby/nbt","last_synced_at":"2025-09-19T07:09:49.220Z","repository":{"id":55567204,"uuid":"44314784","full_name":"rickselby/NBT","owner":"rickselby","description":"PHP parser/writer for the Minecraft NBT format","archived":false,"fork":false,"pushed_at":"2024-11-23T08:43:07.000Z","size":281,"stargazers_count":17,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-10T00:42:14.863Z","etag":null,"topics":["minecraft","nbt","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rickselby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-15T12:06:29.000Z","updated_at":"2024-09-13T13:10:08.000Z","dependencies_parsed_at":"2023-12-16T13:57:31.453Z","dependency_job_id":"66737640-0786-41be-8d60-2eb36180e8b3","html_url":"https://github.com/rickselby/NBT","commit_stats":{"total_commits":96,"total_committers":11,"mean_commits":8.727272727272727,"dds":"0.44791666666666663","last_synced_commit":"e57fc4fb6a5f0cdd9a0f361550a27f735fe6c4e6"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickselby%2FNBT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickselby%2FNBT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickselby%2FNBT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickselby%2FNBT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickselby","download_url":"https://codeload.github.com/rickselby/NBT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230423559,"owners_count":18223435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["minecraft","nbt","php"],"created_at":"2024-10-15T01:12:05.812Z","updated_at":"2025-09-19T07:09:44.171Z","avatar_url":"https://github.com/rickselby.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nThis is a Named Binary Tag parser based upon the specification by Markus Persson.\n\nFrom 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.\"\n\nNBT data is also used in region files, which store the data for Minecraft worlds.\n\n**Requires the GMP Extension for PHP on 32-bit builds.**\n\n## Installing\n### Composer\n\nThe library can be pulled in using composer; add the following to your composer.json:\n\n```\n{\n    \"require\": {\n        \"rickselby/nbt\": \"~4.0\"\n    }\n}\n```\n\n## Usage\n\nReading in from files, resources, or strings:\n```php\n$nbtService = new \\Nbt\\Service(new \\Nbt\\DataHandler());\n$tree = $nbtService-\u003eloadFile('filename.nbt');\n$tree = $nbtService-\u003ereadFilePointer($fPtr);\n$tree = $nbtService-\u003ereadString($nbtString);\n```\n\nThen writing to a file, a resource, or returning a string:\n```php\n$nbtService-\u003ewriteFile('filename.nbt', $tree);\n$nbtService-\u003ewriteFilePointer($fPtr, $tree);\n$nbtString = $nbtService-\u003ewriteString($tree);\n```\n\nTo look through a tree:\n```php\necho $tree-\u003egetName();\n$type = $tree-\u003egetType();\n\n// Value isn't set for Lists and Compounds; those nodes have children instead\n$value = $tree-\u003egetValue();\n\n$sectionsNode = $tree-\u003efindChildByName('Sections');\n```\n\nTo update a tree:\n```php\n$node-\u003esetName('Name');\n$node-\u003esetValue(123456);\n```\n\nTo create new nodes:\n```php\n// This is pretty useless on it's own really\n$node = \\Nbt\\Tag::tagByte('aByte', 0x0f);\n\n// You'll be building trees with Compounds and Lists mostly; both take an array of nodes as their values\n$tree = \\Nbt\\Tag::tagCompound('aCompound', [\n    \\Nbt\\Tag::tagByte('aByte', 0x0f),\n    \\Nbt\\Tag::tagInt('aNumber', 12345),\n]);\n\n// Child tags for lists do not require names, as they are not named - and they must match the payload of the list\n$tree = \\Nbt\\Tag::tagList('aList', \\Nbt\\Tag::TAG_STRING, [\n    \\Nbt\\Tag::tagString('', 'firstString'),\n    \\Nbt\\Tag::tagString('', 'secondString'),\n]);\n```\n\n## History\n\nThe original PHP NBT package was written by [TheFrozenFire](//github.com/TheFrozenFire/PHP-NBT-Decoder-Encoder).\n\nThis 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.\n\nThe returned format - an array - isn't ideal for creating your own NBT data, and some kind of wrapper was required to assist in creation.\n\nI 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickselby%2Fnbt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickselby%2Fnbt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickselby%2Fnbt/lists"}