nathan818/php-minecraft-pinger

This package is abandoned and no longer maintained. No replacement package was suggested.

Ping minecraft PC servers from PHP.

1.0.0 2016-10-19 23:34 UTC

This package is not auto-updated.

Last update: 2023-07-08 13:01:52 UTC


README

Ping minecraft PC servers from PHP. Support Minecraft 1.7+ (works with Spigot, Bukkit, ...).

Installation

This library is published on packagist.org, so you can add it to your composer.json file for an easy installation:

composer require nathan818/php-minecraft-pinger

Example

Ping a server:

<?php
include(__DIR__ . '/vendor/autoload.php');

use MinecraftPinger\MinecraftPinger;
use MinecraftPinger\MinecraftPingException;

$pinger = new MinecraftPinger('mc.hypixel.net', 25565); // Port is optional
try
{
    $pingResponse = $pinger->ping();
    echo 'There are ' . $pingResponse->players->online . ' players online on Hypixel!' . "\n";
}
catch (MinecraftPingException $e)
{
    // An error has occurred
    echo $e->getMessage();
}