Usage
composer require stilling/minecraft-rconuse Stilling\MinecraftRcon\Exceptions\RconException;
use Stilling\MinecraftRcon\Rcon;
$rcon = new Rcon("mc.example.com", 25575, "super-secret-password", timeout: 5);
try {
$rcon->connect();
$players = $rcon->sendCommand("list");
// "There are 2 of a max of 20 players online: Alex, Steve"
} catch (RconException $e) {
// Log the error or show it to the user.
} finally {
$rcon->disconnect();
}Details
- A command can be at most 1446 bytes. The client throws a
PacketExceptionfor a longer command and does not send it. isConnected()tells you if the connection is still usable.- Requires PHP 8.3 or later.
data get returns as PHP values or typed tags.