thanhct/firebase-php

Firebase 管理SDK


README

从您的PHP应用程序与 Google Firebase 交互。

Current version Supported PHP version Build Status GitHub license Total Downloads Maintainability Test Coverage

快速入门

完整文档请访问 firebase-php.readthedocs.io

composer require thanhct/firebase-php 3.9.4
<?php

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

use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;

$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/google-service-account.json');

$firebase = (new Factory)
    ->withServiceAccount($serviceAccount)
    ->withDatabaseUri('https://my-project.firebaseio.com')
    ->create();

$database = $firebase->getDatabase();

$newPost = $database
    ->getReference('blog/posts')
    ->push([
        'title' => 'Post title',
        'body' => 'Post body'
    ]);

$newPost->getChild('title')->set('Changed post title');

$newPost->remove();

对于错误和缺失功能,请使用 问题跟踪器

对于一般支持,请加入 https://firebase.community/#php 频道。