Download the PHP package cartograph/minecraft-nbt without Composer

On this page you can find all versions of the php package cartograph/minecraft-nbt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package minecraft-nbt

Minecraft NBT

A pure-PHP library for reading, writing, and manipulating Minecraft's NBT (Named Binary Tag) format, in both binary (file and network) form and SNBT.

Packagist Version Total Downloads PHP Version

Features

Requirements

Installation

Install via Composer:

Quick start

Build a tag tree and write it to a file:

That's a complete, runnable example, with no fixtures and no setup. The output is a GZip-compressed binary NBT file with a TAG_Compound root containing one string and one int child.

To read it back:

Concepts

NBT is a tree of typed tags. Every tree has a CompoundTag at its root, which is an ordered map of named children. Children can be other compounds (nesting), ListTags (homogeneous, ordered sequences of tags), or any of the leaf types: Byte, Short, Int, Long, Float, Double, String, ByteArray, IntArray, or LongArray.

The same tree can be serialised two ways:

This library reads, writes, parses, and renders both.

Usage

Read a binary file

readFile auto-detects GZip and Zlib compression from the file's leading bytes; uncompressed files work too.

Write a binary file

GZip is the default. Pass a different Compression to override.

The third argument is the root tag's name (most files use an empty string).

Parse SNBT

parseSnbt accepts the full SNBT grammar including 1.21.5 extensions: typed-array prefixes, signed/unsigned suffixes, hex/binary literals, underscore digit separators, and trailing commas.

Render SNBT

Two modes via SnbtOptions: compact (default) and pretty.

SnbtOptions also lets you force-quote keys (quoteKeys: true), pick a preferred quote style (quoteStyle: QuoteStyle::Single), and choose the indentation unit.

Network format (Minecraft 1.20.2+)

The network protocol uses an unnamed root compound. Nbt::readNetworkBinary and Nbt::writeNetworkBinary handle it.

Class overview

All tag classes live in the Cartograph\NBT\Tags namespace.

Class Holds Notes
ByteTag int -128 to 127
ShortTag int -32 768 to 32 767
IntTag int signed 32-bit
LongTag int signed 64-bit (full PHP int range)
FloatTag float IEEE 754 single-precision
DoubleTag float IEEE 754 double-precision
StringTag string UTF-8, max 65 535 bytes
ByteArrayTag int[] each element in ByteTag range
IntArrayTag int[] each element in IntTag range
LongArrayTag int[] (PHP int always fits)
CompoundTag array<string, Tag<*>> ordered map of named children
ListTag list<Tag<*>> homogeneous; element type declared at construction

The Nbt facade has a factory method for each (Nbt::byte(), Nbt::compound(), ...) that returns the corresponding tag instance.

Compatibility

This library targets the Java Edition NBT format. All 13 tag types (including TAG_End for empty lists) are supported.

Bedrock Edition's NBT variant (little-endian, varint-prefixed) is not supported.

Contributing

Bug reports, feature requests, and pull requests are welcome at github.com/cartographgg/minecraft-nbt. See CONTRIBUTING.md for development setup and the required checks (tests, static analysis, code style, and mutation testing). Each check has a Composer script: composer test, composer static, composer style, and composer mutation.

License

Released under the MIT License. © Cartograph contributors.


Maintained as part of Cartograph, a Minecraft server directory and monitoring platform. The library is self-contained and has no Cartograph-specific behaviour; use it anywhere you need to work with NBT data in PHP.


All versions of minecraft-nbt with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ext-zlib Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cartograph/minecraft-nbt contains the following files

Loading the files please wait ...