-
-
Notifications
You must be signed in to change notification settings - Fork 1
Quick Start
Home · Installation · Servers and ports
<?php
require __DIR__ . '/vendor/autoload.php';
use GameQ\GameQ;
$gameQ = new GameQ();
$gameQ->addServer([
'id' => 'main',
'type' => 'css',
'host' => '127.0.0.1:27015',
]);
$results = $gameQ->process();
$server = $results['main'];
printf(
"%s is %s\n",
$server['gq_hostname'] ?? 'Server',
$server['gq_online'] ? 'online' : 'offline',
);host contains the client/connect port. GameQ calculates a different query port for protocols with a known offset.
$gameQ = new GameQ();
$gameQ->addServers([
[
'id' => 'source',
'type' => 'css',
'host' => '192.0.2.10:27015',
],
[
'id' => 'quake',
'type' => 'cod4',
'host' => '192.0.2.20:28960',
],
[
'id' => 'unreal',
'type' => 'ut2004',
'host' => '192.0.2.25:7777',
],
[
'id' => 'voice',
'type' => 'teamspeak3',
'host' => '192.0.2.30:9987',
'options' => [
'query_port' => 10011,
],
],
]);
$gameQ->setOption('timeout', 5);
$results = $gameQ->process();The result is keyed by each explicit id. Without an id, GameQ uses the resolved address and client port.
servers.json:
[
{
"id": "public-css",
"type": "css",
"host": "192.0.2.10:27015"
},
{
"id": "public-minecraft",
"type": "minecraft",
"host": "192.0.2.20:25565"
}
]$gameQ = new GameQ();
$gameQ->addServersFromFiles(__DIR__ . '/servers.json');
$results = $gameQ->process();An array of JSON filenames is also accepted. Missing, unreadable, invalid, or non-array files are ignored. Individual entries still go through normal server validation.
Normalization is enabled by default. Add optional filters before processing:
$gameQ
->addFilter('stripcolors')
->addFilter('secondstohuman', [
'timekeys' => ['time', 'uptime'],
]);See filters and understanding results for the complete behavior.
process() does not remove configured servers. Call clearServers() before filling the same instance with a different list:
$firstResults = $gameQ->process();
$gameQ->clearServers()->addServer($nextServer);
$nextResults = $gameQ->process();For large lists, continue with bulk queries and performance.
Getting started
Configuration
Guides
Reference
Development
Migration