Interact with Google Firebase from your PHP application.
Full documentation at firebase-php.readthedocs.io.
composer require kreait/firebase-php ^3.0
<?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();
For errors and missing features, please use the issue tracker.
For general support, join the #php
channel at https://firebase.community/.