1. Go to this page and download the library: Download jasonw4331/libpmquery 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/ */
jasonw4331 / libpmquery example snippets
use jasonw4331\libpmquery\PMQuery;
use jasonw4331\libpmquery\PmQueryException;
$query = PMQuery::query("my.server.net", 19132);
$query['GameName']; // Returns the server software being used
$query['HostName']; // Returns the server host name
$query['Protocol']; // Returns the protocol version allowed to connect
$query['Version']; // Returns the client version allowed to connect
$query['Players']; // Returns the number of players on the server currently
$query['MaxPlayers']; // Returns the maximum player count of the server
$query['ServerId']; // Returns the raknet server id
$query['Map']; // Returns the default world name
$query['GameMode']; // Returns the default gamemode
$query['NintendoLimited']; // Returns the status of Nintendo's limitation to join
$query['IPv4Port']; // Returns the ipv4 port number
$query['IPv6Port']; // Returns the ipv6 port number
$query['Extra']; // I still don't know what this info is
try{
$query = PMQuery::query("my.server.net", 19133);
$players = (int) $query['Players'];
Server::getInstance()->getLogger()->info("There are ".$players." on the queried server right now!");
}catch(PmQueryException $e){
//you can choose to log this if you want
Server::getInstance()->getLogger()->info("The queried server is offline right now!");
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.