PHPackages                             gs2/gs2-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gs2/gs2-php-sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

gs2/gs2-php-sdk
===============

1.4.322(1mo ago)1839Apache-2.0PHPPHP &gt;= 8.0CI failing

Since Oct 6Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/gs2io/gs2-php-sdk)[ Packagist](https://packagist.org/packages/gs2/gs2-php-sdk)[ RSS](/packages/gs2-gs2-php-sdk/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (4)Versions (295)Used By (0)

[⇒README in English](README-en.md)

gs2-php-sdk
===========

[](#gs2-php-sdk)

Game Server Services() を PHP で利用するためのSDKです。

Game Server Services とは
-----------------------

[](#game-server-services-とは)

Game Server Services(GS2) とはゲーム開発に特化したバックエンドサーバサービス(BaaS)です。

GS2は、ゲーム開発者の効率化を目指して生まれた汎用ゲームサーバーのソリューションであり、Games as a Service(GaaS) や Live Gaming などをサポートしています。

このサービスでは、プレイヤーデータの柔軟な管理やデータ分析が可能であり、ゲーム内の資源の流通や消費量を適切に分析して健全な環境を維持することができます。 さらに、ストーリー進行管理や所持品管理などの機能を提供し、ゲームの収益化やプレイヤーエンゲージメントの向上に貢献します。 GS2は、オンライン機能をサポートし、ゲーム開発者がデータの分析や経済管理を容易に行えるようにすることで、ゲームの成功を支援します。

Getting Started
---------------

[](#getting-started)

SDKを利用するには GS2 のクレデンシャルが必要です。 [GS2のセットアップ](https://docs.gs2.io/ja/get_start/tutorial/setup_gs2/) の手順に従ってクレデンシャルを発行してください。

### 動作条件

[](#動作条件)

- PHP7.1+

[⇒GS2の利用を開始 - SDK - 各種プログラミング言語](https://docs.gs2.io/ja/get_start/#%E5%90%84%E7%A8%AE%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E8%A8%80%E8%AA%9E)

### サンプル

[](#サンプル)

GS2-Account の例

#### 初期化処理

[](#初期化処理)

```
use Gs2\Account\Gs2AccountRestClient;
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2AccountRestClient(
    $session
);
```

#### 同期処理

[](#同期処理)

```
use Gs2\Account\Model\ScriptSetting;
use Gs2\Account\Request\CreateNamespaceRequest;
use Gs2\Core\Exception\Gs2Exception;
use PHPUnit\Framework\Assert;

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName('namespace-0001')
            ->withAuthenticationScript(
                (new ScriptSetting())
                    ->withTriggerScriptId('script-0001')
            )
    );

    Assert::assertNotNull($result->getItem());
    Assert::assertEquals('namespace-0001', $result->getItem()->getName());
    Assert::assertEquals('script-0001', $result->getItem()->getAuthenticationScript()->getTriggerScriptId());
} catch (Gs2Exception $e) {
    Assert::fail($e->getMessage());
}
```

#### 非同期処理

[](#非同期処理)

```
use Gs2\Account\Model\ScriptSetting;
use Gs2\Account\Request\CreateNamespaceRequest;
use Gs2\Account\Result\CreateNamespaceResult;
use Gs2\Core\Exception\Gs2Exception;
use PHPUnit\Framework\Assert;

// 非同期処理をハンドリングするための Promise が返る
$promise = $client->createNamespaceAsync(
    (new CreateNamespaceRequest())
        ->withName('namespace-0001')
        ->withAuthenticationScript(
            (new ScriptSetting())
                ->withTriggerScriptId('script-0001')
        )
)->then(
    function (CreateNamespaceResult $result) {
        // コールバック形式でハンドリングしたい場合は成功時のハンドラーをここに記述
        Assert::assertNotNull($result->getItem());
        Assert::assertEquals('namespace-0001', $result->getItem()->getName());
        Assert::assertEquals('script-0001', $result->getItem()->getAuthenticationScript()->getTriggerScriptId());
    },
    function (Gs2Exception $e) {
        // コールバック形式でハンドリングしたい場合は失敗時のハンドラーをここに記述
        Assert::fail($e->getMessage());
    }
);

try {
    // Promise を wait することで処理が実行される。戻り値には成功時の結果が返り、失敗時には例外が発生する。
    $result = $promise->wait();
    Assert::assertNotNull($result->getItem());
    Assert::assertEquals('namespace-0001', $result->getItem()->getName());
    Assert::assertEquals('script-0001', $result->getItem()->getAuthenticationScript()->getTriggerScriptId());
} catch (Gs2Exception $e) {
    Assert::fail($e->getMessage());
}
```

Promise に関するドキュメントは  こちらをご確認ください。

SDK の詳細仕様
---------

[](#sdk-の詳細仕様)

各種サービス・通信方式の詳細は

[⇒API リファレンス](https://docs.gs2.io/ja/api_reference/)

[⇒API リファレンス - 初期化処理](https://docs.gs2.io/ja/api_reference/initialize/)

をご参照ください。

*本プロジェクトのコードは gs2-php-sdk-core 以外は全て自動生成されているため、個別に Pull-Request を頂いても対応できません。*

###  Health Score

56

↑

FairBetter than 97% of packages

Maintenance94

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Recently: every ~59 days

Total

293

Last Release

30d ago

Major Versions

0.2.0 → 1.0.02020-02-26

PHP version history (2 changes)0.2.0PHP &gt;= 7.1.0

1.4.0PHP &gt;= 8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16728854?v=4)[Kazutomo Niwa](/maintainers/niwa-kazutomo)[@niwa-kazutomo](https://github.com/niwa-kazutomo)

---

Top Contributors

[![gs2-ci](https://avatars.githubusercontent.com/u/23280042?v=4)](https://github.com/gs2-ci "gs2-ci (300 commits)")[![niwa-kazutomo](https://avatars.githubusercontent.com/u/16728854?v=4)](https://github.com/niwa-kazutomo "niwa-kazutomo (40 commits)")[![imatakeharuhiko](https://avatars.githubusercontent.com/u/31247577?v=4)](https://github.com/imatakeharuhiko "imatakeharuhiko (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gs2-gs2-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/gs2-gs2-php-sdk/health.svg)](https://phpackages.com/packages/gs2-gs2-php-sdk)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[oat-sa/tao-core

TAO core extension

66143.7k122](/packages/oat-sa-tao-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
