PHPackages                             david-canial/remote-config-tool - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. david-canial/remote-config-tool

ActiveLibrary[HTTP &amp; Networking](/categories/http)

david-canial/remote-config-tool
===============================

PHP client library for Firebase Remote Config (build artifacts only).

v2.0.0(4mo ago)05MITPHPPHP ^8.0

Since Jan 6Pushed 4mo agoCompare

[ Source](https://github.com/david-canial/remote-config-tool)[ Packagist](https://packagist.org/packages/david-canial/remote-config-tool)[ RSS](/packages/david-canial-remote-config-tool/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

david-canial/remote-config-tool
-------------------------------

[](#david-canialremote-config-tool)

**Firebase Remote Config を操作するための PHP クライアントライブラリ**です。

- Google の service account を使って **アクセストークンを取得**。
- **Remote Config の取得**（ETag 付き）。
- **ETag を使った更新** および **force update** をサポート。

シンプルなスクリプト、バッチ処理、既存バックエンドへの組み込みなどに適しています。

---

インストール
------

[](#インストール)

### 必要環境

[](#必要環境)

- PHP 8.0+
- Composer
- Firebase プロジェクトと、`Firebase Remote Config Admin` 権限を持つ service account

Composer でインストールします:

```
composer require david-canial/remote-config-tool
```

---

service account と credentials の準備
---------------------------------

[](#service-account-と-credentials-の準備)

1. **Google Cloud Console** を開きます:

    - 「IAM と管理」→「サービス アカウント」
    - 新しい service account を作成（既存のものを使っても OK）
2. 権限（ロール）の付与:

    - Firebase Remote Config を操作できるロールを付与します。例:
        - `Firebase Remote Config Admin`
        - もしくは同等の権限を含むカスタムロール
3. JSON キーを作成:

    - service account 詳細画面 → 「キー」タブ → 「キーを追加」→「新しいキーを作成」→ JSON
    - ダウンロードした JSON ファイルを、例えば `/path/to/service-account.json` に保存
4. Google 認証用の環境変数を設定:

```
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
```

5. `FIREBASE_PROJECT_ID` を設定:

```
export FIREBASE_PROJECT_ID="your-firebase-project-id"
```

`your-firebase-project-id` は、JSON ファイル内の `projectId` か、Firebase コンソールのプロジェクト ID に対応します。

> Laravel や Symfony などのフレームワークを利用している場合は、これらの値を `.env` に定義し、フレームワーク側で読み込ませても構いません。

---

静的ファサード `RemoteConfig` を使った簡単な利用例
---------------------------------

[](#静的ファサード-remoteconfig-を使った簡単な利用例)

インストールと環境変数の設定が完了したら、`RemoteConfig` ファサードを利用できます:

```
