PHP code example of easyx / php-minecraft-query
1. Go to this page and download the library: Download easyx/php-minecraft-query library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
easyx / php-minecraft-query example snippets
re __DIR__ . '/src/MinecraftPingException.php';
use EasyX\MinecraftPing;
use EasyX\MinecraftPingException;
try {
$query = new MinecraftPing('localhost', 25565);
print_r($query->Query($protocolVersion = 4));
}
catch(MinecraftPingException $e) {
echo $e->getMessage();
}
finally {
if ($query) {
$query->Close();
}
}
re __DIR__ . '/src/MinecraftQueryException.php';
use EasyX\MinecraftQuery;
use EasyX\MinecraftQueryException;
$query = new MinecraftQuery();
try {
$query->Connect('localhost', 25565);
print_r($query->GetInfo());
print_r($query->GetPlayers());
}
catch(MinecraftQueryException $e) {
echo $e->getMessage();
}