packagist kreait/firebase-php 2.0.0-beta2

latest releases: 7.x-dev, dev-dependabot/github_actions/codecov/codecov-action-5.0.7, dev-dependabot/github_actions/codecov/codecov-action-5.0.3...
8 years ago

Changes to 2.0.0-beta1

It seems more than just possible that the ID of a project given in the Google Service Account JSON file is different to the xxx.firebaseio.com subdomain of a Firebase application. It was already possible to pass the URL of the Realtime Database as a second parameter:

$firebase = Firebase::fromServiceAccount(
    __DIR__.'/google-service-account.json',
    'https://my-project.firebaseio.com'
);

Now a more visible method is available to do the same:

$firebase = Firebase::fromServiceAccount(__DIR__.'/google-service-account.json')
    ->withDatabaseUri('https://my-project.firebaseio.com');

Full list of changes: 2.0.0-beta1...2.0.0-beta2


Starting with version 2.0, this SDK is PHP7 only! The SDK is considered stable, but will stay in beta until the documentation at http://firebase-php.readthedocs.io has been finished.

Quickstart

Create a service account as described in the Firebase Docs and download the service account JSON file, or retrieve a database secret from your Firebase application's project settings page.

$firebase = Firebase::fromServiceAccount(__DIR__.'/google-service-account.json');
// or
$firebase = Firebase::fromDatabaseUriAndSecret(
    'https://<project>.firebaseio.com',
    '<database secret>'
);

$db = $firebase->getDatabase();

$fullTree = $db
    ->getReference('/')
    ->orderByKey(SORT_DESC)
    ->getValue(); // Shortcut for ->getSnapshot()->getValue()

print_r($fullTree);

Don't miss a new firebase-php release

NewReleases is sending notifications on new releases.