PHP code example of softcreatr / gameq

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

    

softcreatr / gameq example snippets




ameQ\GameQ;

$gameQ = new GameQ();
$gameQ->addServers([
    [
        'id' => 'source-server',
        'type' => 'css',
        'host' => '192.0.2.10:27015',
    ],
    [
        'id' => 'unreal-server',
        'type' => 'ut2004',
        'host' => '192.0.2.20:7777',
    ],
]);

$gameQ
    ->setOption('timeout', 5)
    ->setOption('max_servers_per_batch', 50);

$results = $gameQ->process();

if ($results['source-server']['gq_online']) {
    printf(
        "%s: %d/%d players\n",
        $results['source-server']['gq_hostname'],
        $results['source-server']['gq_numplayers'],
        $results['source-server']['gq_maxplayers'],
    );
}

use GameQ\GameQ;
use GameQ\Http\GuzzleClient;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;

$factory = new HttpFactory();
$gameQ = (new GameQ())->setHttpClient(new GuzzleClient(
    new Client(['proxy' => 'http://proxy.example:8080']),
    $factory,
    $factory,
));