CheckHost PHP is a lightweight PHP wrapper for interacting with the check-host.net API, allowing you to run PING, HTTP, TCP, UDP, DNS, TRACEROUTE checks from a variety of global nodes. It includes flexible country/node filtering and comprehensive result parsing.
- Get real-time availability data from multiple global nodes
- Supports:
ping,http,tcp,udp,dns,traceroute - Filter nodes by country code, country name, or domain
- Collect results from specific or all available nodes
- Parse and structure response data (avg/min/max ping, jitter, status, etc.)
Install via Composer:
composer require ilyagvc/checkhost$checkHost = new CheckHost(
array|null $selectedCountries = null,
bool $except = false,
string|null $proxy = null,
int $timeout = 60
);| Parameter | Type | Description |
|---|---|---|
$selectedCountries |
array, null |
Country name(s), ISO country code(s), or node domain(s) to include/exclude (null = all available nodes) (default = null) |
$except |
bool |
If true, excludes the specified countries instead of including them (default = false) |
$proxy |
string, null |
Optional proxy for curl requests (default = null) |
$timeout |
int |
Request timeout (seconds) for waiting on test results (default = 60) |
Filters nodes based on country names, codes, or node domains.
| Parameter | Type | Description |
|---|---|---|
$countries |
array, null |
Country name(s), ISO country code(s), or node domain(s) to include/exclude (null = all available nodes) (default = null) |
$except |
bool |
If true, excludes the specified countries instead of including them (default = false) |
Returns the currently selected and filtered node list.
No parameters.
Fetches the raw IP list of all available nodes from check-host.net.
No parameters.
Refreshes and re-applies node filters to fetch the latest node list.
No parameters.
Sends a check request of a given type to selected nodes.
| Parameter | Type | Description |
|---|---|---|
$host |
string |
The target domain or IP to check |
$type |
string |
Type of check: one of ping, http, tcp, udp, dns, traceroute |
$maxNodes |
int |
Maximum number of nodes to use. Any value other than 0 overrides the selected nodes and uses up to the specified number of available nodes (0 = use selected nodes) (default = 0) |
Fetches the result of a previously sent check request.
| Parameter | Type | Description |
|---|---|---|
$requestId |
string |
ID returned by sendRequest() |
Combines sendRequest() and getResults() into a single call, returning structured data.
| Parameter | Type | Description |
|---|---|---|
$host |
string |
The target domain or IP to check |
$type |
string |
Type of check: one of ping, http, tcp, udp, dns, traceroute |
$maxNodes |
int |
Maximum number of nodes to use. Any value other than 0 overrides the selected nodes and uses up to the specified number of available nodes (0 = use selected nodes) (default = 0) |
Performs all checks (ping, http, tcp, udp, dns, traceroute) on the given host.
| Parameter | Type | Description |
|---|---|---|
$host |
string |
The target domain or IP to check |
Sets or updates a proxy to be used for all cURL HTTP requests.
| Parameter | Type | Description |
|---|---|---|
$proxy |
string |
Proxy address, e.g., http://127.0.0.1:8080 |
Sets the timeout for all result fetching requests.
| Parameter | Type | Description |
|---|---|---|
$seconds |
int |
Timeout duration in seconds |
<?php
use ILYAGVC\CheckHost\CheckHost;
require 'vendor/autoload.php';
$checkHost = new CheckHost();
$result = $checkHost->runCheck('https://www.google.com', 'ping', 2);
print_r($result);Array
(
[host] => www.google.com
[type] => ping
[results] => Array
(
[Germany] => Array
(
[result_summary] => Array
(
[ping] => 4/4
[average_ms] => 1
...
)
...
)
[Iran] => ...
)
)<?php
use ILYAGVC\CheckHost\CheckHost;
require 'vendor/autoload.php';
$checkHost = new CheckHost();
$result = $checkHost->fullCheck('https://www.google.com');
print_r($result);Array
(
[Austria] => Array
(
[ping] => [...]
[http] => [...]
[tcp] => [...]
[udp] => [...]
[dns] => [...]
[traceroute] => [...]
)
...
)Filter to only Germany and Austria nodes:
$checkHost = new CheckHost(['Germany', 'AT']);Exclude France:
$checkHost = new CheckHost(['France'], true);$checkHost->setProxy('http://127.0.0.1:8080');
$checkHost->setTimeout(10);Developed by ILYAGVC Feel free to open issues or PRs!