nathan818 / php-minecraft-pinger
Ping minecraft PC servers from PHP.
Installs: 353
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
pkg:composer/nathan818/php-minecraft-pinger
Requires
- php: >=7.0.0
- nathan818/phpuc-net-sockets: ^1.0
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(); }