1. Go to this page and download the library: Download stilling/minecraft-rcon 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/ */
stilling / minecraft-rcon example snippets
use Stilling\MinecraftRcon\Rcon;
$rcon = new Rcon("mc.example.com", 25575, "super-secret-password");
$rcon->connect();
$rcon->sendCommand("list");
// "There are 2 of a max of 20 players online: Alex, Steve"
$rcon->disconnect();
use 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");
} catch (RconException $e) {
// Log the error or show it to the user.
} finally {
$rcon->disconnect();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.