PHP code example of fragland / minestat

1. Go to this page and download the library: Download fragland/minestat 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/ */

    

fragland / minestat example snippets



 new MineStat("frag.land");
// Bedrock/Pocket Edition explicit query example
//$ms = new MineStat("minecraft.frag.land", 19132, 5, MineStat::REQUEST_BEDROCK);
printf("Minecraft server status of %s on port %s:<br>", $ms->get_address(), $ms->get_port());
if($ms->is_online())
{
  printf("Server is online running version %s with %s out of %s players.<br>", $ms->get_version(), $ms->get_current_players(), $ms->get_max_players());
  if($ms->get_request_type() == "Bedrock/Pocket Edition")
    printf("Game mode: %s<br>", $ms->get_mode());
  printf("Message of the day: %s<br>", $ms->get_motd());
  printf("Message of the day without formatting: %s<br>", $ms->get_stripped_motd());
  printf("Latency: %sms<br>", $ms->get_latency());
  printf("Connected using protocol: %s<br>", $ms->get_request_type());
}
else
{
  printf("Server is offline!<br>");
}