Minecraft library for retrieving server data (players, motd, favicon..)

v1.0.2 2022-11-14 00:15 UTC

This package is auto-updated.

Last update: 2024-07-14 03:58:53 UTC


🛰️ Minecraft PHP library for retrieving server query data


Required at least PHP 7.2

composer require php-minecraft/minecraft-query

Example usage


require __DIR__ . '/../vendor/autoload.php';

use PHPMinecraft\MinecraftQuery\MinecraftQueryResolver;

Minecraft v1.7+

$resolver = new MinecraftQueryResolver('', 25565);

$result = $resolver->getResult();

Minecraft <= v1.6

$resolver = new MinecraftQueryResolver('', 25565);


$result = $resolver->getResult();

Autodetect minecraft version (if 1.7+ query fails, older will be used)

$resolver = new MinecraftQueryResolver('', 25565);

$result = $resolver->getResult($tryOldQueryProtocolPre17 = true);

Result data

$result->getMaxPlayers() // integer
$result->getOnlinePlayers() // integer
$result->getPlayersSample() // array (players -> sample at
$result->getVersion() // string
$result->getProtocolVersion() // integer
$result->getMessageOfTheDay() // string
$result->getLatency() // integer (ms)
$result->getFavicon() // string or null


// use this cosntructor if you dont want separate address to host and port
$resolver = MinecraftQueryResolver::fromAddress('');

// use this method if you want raw data in array retrieved from minecraft server
$rawData = $resolver->getRawData();

// use this method if you want construct MinecraftQueryResult from raw data
$result = MinecraftQueryResult::fromRawData($rawData);

Library (socket logic) is inspired by xPaw/PHP-Minecraft-Query