Changes to 2.0.0-beta2
- A
PermissionDenied
exception is thrown when a request violates the
Firebase Realtime Database rules - An
IndexNotDefined
exception is thrown when a Query is performed on an unindexed subtree - Removes the query option to sort results in descending order.
- Nice in theory, conflicted in practice: when combined with
limitToFirst()
orlimitToLast()
,
results were lost because Firebase sorts in ascending order and limits the results before
we can process them further.
- Nice in theory, conflicted in practice: when combined with
- Adds a new Method
Reference::getChildKeys()
to retrieve the key names of a reference's children- This is a convenience method around a shallow query, see
shallow queries in the Firebase docs
- This is a convenience method around a shallow query, see
Full list of changes: 2.0.0-beta2...2.0.0-beta3
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);