PHP code example of dev-lancer / minecraft-status

1. Go to this page and download the library: Download dev-lancer/minecraft-status 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/ */

    

dev-lancer / minecraft-status example snippets



use \DevLancer\MinecraftStatus\Query;

t = 25565; //from query.port
$timeout = 3;
$resolveSVR = true;

$query = new Query($host, $port, $timeout, $resolveSVR);
$query->connect();
print_r($query->getInfo());


use \DevLancer\MinecraftStatus\QueryBedrock;

32;
$timeout = 3;
$resolveSVR = true;

$query = new QueryBedrock($host, $port, $timeout, $resolveSVR);
$query->connect();
print_r($query->getInfo());


use \DevLancer\MinecraftStatus\Ping;
use \DevLancer\MinecraftStatus\PingPreOld17;



$ping = new Ping($host, $port, $timeout, $resolveSVR);
//$ping = new PingPreOld17($host, $port, $timeout, $resolveSVR); //use when version is older than Minecraft 1.7
$ping->connect();
print_r($ping->getInfo());

setTimeout(int $timeout): void

setEncoding(string $encoding): void

connect(): self

disconnect(): void

getInfo(): array

getPlayers(): array

getCountPlayers(): int

getMaxPlayers(): int

getFavicon(): string

getDelay(): int

getMotd(): string

getProtocol(): int

getHost(): string

getPort(): int

getEncoding(): string

getTimeout(): int

isConnected(): bool

isResolveSRV(): bool