定制 gigrawars-open/game-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gigrawars-open/game-client

最新稳定版本:0.1.0

Composer 安装命令:

composer require gigrawars-open/game-client

包简介

A PHP rest client library for GigraWars game instances

README 文档

README

A simple PHP client library to communicate with the GigraWars Game API. The client hides HTTP details (PSR-18/HTTPlug) and offers convenient methods for common endpoints (e.g., account/player data, planets, etc.).

Requirements

  • PHP: ^8.2
  • Composer

Installation

via composer:

composer require gigrawars-open/game-client

Quick start

<?php

use GigraWars\Open\GameClient\Client;
use GigraWars\Open\GameClient\Utils\Coordinate;
use GigraWars\Open\GameClient\Utils\GameEnvironment;

require __DIR__ . '/vendor/autoload.php';

$client = new Client();

// Set base URL – either as a string or by using predefined environments
$client->setUrl(GameEnvironment::UNI5);
// or: $client->setUrl('https://uni5.gigrawars.de');

// Authenticate via API token
$client->authenticateWithToken('MY-API-TOKEN');

// Account: Get my own data
$me = $client->account()->me();

// Account: Get all my planets
$planets = $client->account()->planets();

// Account: Get a single planet by coordinate
$planet = $client->account()->planet(Coordinate::create(1, 2, 4));

// BattleReport: Get a single battle report by ID
$report = $client->battleReport()->single('36b76947-567f-4915-8a31-ffcf90e4698d');

Using predefined game environments

$client = new Client(url: GameEnvironment::MIRAGE);
$client->authenticateWithToken('MY-API-TOKEN');
$me = $client->account()->me();

Create coordinates easily

use GigraWars\Open\GameClient\Utils\Coordinate;

$c1 = Coordinate::create(1, 2, 3);
$c2 = Coordinate::createByString('1:2:3');

var_dump($c1->isEquals($c2)); // true

Error handling

  • General client errors are thrown as GigraWars\Open\GameClient\Exception\GigraWarsGameClientException.

Example:

use GigraWars\Open\GameClient\Exception\GigraWarsGameClientException;

try {
    $client->authenticateWithToken('TOKEN');
    $me = $client->account()->me();
} catch (GigraWarsGameClientException $e) {
    // Logging, retry, user notice, etc.
    error_log($e->getMessage());
}

Development

  • Run tests:
    • vendor/bin/phpunit
  • Static analysis:
    • vendor/bin/phpstan analyse
  • Coding standards (PHP_CodeSniffer):
    • vendor/bin/phpcs

License

This project is released under the MIT License. See LICENSE.md.

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-19