Kreait\Firebase\Database::getRules()
has been deprecated in favor ofKreait\Firebase\Database::getRuleSet()
- Fixed the inability to correctly parse a response from the Firebase Batch Messaging when
Messaging::sendMulticast()
orMessaging::sendAll()
was used with only one recipient.
- The third parameter of
Kreait\Firebase\Auth::verifyIdToken()
($allowTimeInconsistencies
) has been deprecated because, since 4.25.0, a default leeway of 5 minutes is already applied. Using it will trigger aE_USER_DEPRECATED
warning. - Previously the "verified" status of an user email could be
null
if not defined - it will now befalse
by default
- Fixed a deprecation warning when getting the root reference with
Kreait\Firebase\Database::getReference()
without giving a path.
- When sending multiple messages at once, it can happen in some cases that the HTTP sub-responses can not be parsed which would cause an exception. Until we figure out the cause, those exceptions are now caught, with the caveat that the resulting send-report is not correct (it will show 0 successes and 0 failures even if the messages were successfully sent).
Kreait\Firebase\Factory
now exposes the methods to create the single components (Auth, Messaging, Remote Config,
Storage) directly in order to enable its usage in kreait/laravel-firebase.
- Added
Kreait\Firebase\Messaging::sendAll()
to send up to 100 messages to multiple targets (tokens, topics, and conditions) in one request. (Documentation) - A condition will now ensure that no more than five topics are provided. Previously, the Firebase REST API would have rejected the message with a non-specific "Invalid condition expression provided."
- The Remote Config history can now be filtered. (Documentation)
- A published Remote Config template now contains a version that can be retrieved with
Kreait\Firebase\RemoteConfig\Template::getVersion()
- The parameters of a Remote Config template can now be retrieved with
Kreait\Firebase\RemoteConfig\Template::getParameters()
Kreait\Firebase\Messaging::sendMulticast()
now makes full use of the FCM batch API, resulting in substantial performance improvements.- Values passed to
Kreait\Firebase\Messaging\MessageData::withData()
will now be cast to strings instead of throwing InvalidArgument exceptions when they are not strings.
- The SDK is now able to handle connection issues more gracefully. The following exceptions will now be thrown
when a connection could not be established:
Kreait\Firebase\Auth\ApiConnectionFailed
Kreait\Firebase\Database\ApiConnectionFailed
Kreait\Firebase\Messaging\ApiConnectionFailed
Kreait\Firebase\RemoteConfig\ApiConnectionFailed
- It is now possible to retrieve extended information about application instances related to a registration token, including the topics an application instance/registration token is subscribed to. (Documentation)
- Each component now has its own catchable exception interface, e.g.
Kreait\Firebase\Exception\AuthException
orKreait\Firebase\Exception\DatabaseException
. - The following exceptions are now interfaces implemented by specific errors instead of extensible classes:
Kreait\Firebase\Exception\AuthException
Kreait\Firebase\Exception\DatabaseException
(new)Kreait\Firebase\Exception\MessagingException
Kreait\Firebase\Exception\RemoteConfigException
Kreait\Firebase\Auth\CustomTokenViaGoogleIam
is no longer using deprecated methods to build a custom token.- Getting requests and responses from exceptions is now considered deprecated. If you want to debug HTTP requests, use the Firebase factory to debug the HTTP client via configuration or an additional middleware.
- Notifications can now be provided with an image URL (Documentation)
- You can use
Kreait\Firebase\Messaging\RawMessageFromArray(array $data)
to create a message without the SDK checking it for validity before sending it. This gives you full control over the sent message, but also means that you have to send/validate a message in order to know if it's valid or not. (Documentation) - It is now possible to add platform independent FCM options to a message. (Documentation)
- Removed ability to specify multiple message targets (Condition/Token/Topic) at once when creating an FCM message
through
CloudMessage::fromArray()
. Previously, only the first matched target was used. Now, anInvalidArgument
exception is thrown.
This is an under-the-hood release and should not affect any existing functionality:
- Internal classes have been marked as
@internal
- Micro-Optimizations
- PHPStan's analysis level has been set to
max
psr/simple-cache
was implicitely required and is now explicitely required- Simplified the Travis CI configuration (this should now enably PRs to be tested without errors)
- When verifying ID tokens a leeway of 5 minutes is applied when verifying time based claims
- You can now send one message to multiple devices with
Kreait\Firebase\Messaging::sendMulticast($message, $deviceTokens)
(Documentation)
- Custom attributes can now be deleted from a user with
Kreait\Firebase\Auth::deleteCustomUserAttributes($uid)
(#300)
Kreait\Firebase\Messaging\CloudMessage
can now be created without a target. The existence of a message target is now validated on send. This enables re-using a message for multiple targets.- Improved reliability of discovering a ServiceAccount from environment variables. (huge thanks to @Shifu33 for helping to find and test this)
- It is now possible to disable the ServiceAccount discovery by calling
Kreait\Firebase\Factory::withDisabledAutoDiscovery()
(Documentation)
- Fixed return value on
Kreait\Firebase\Database\Transaction::set()
: it returned the HTTP response, but should return nothing.
- You can now wrap Realtime Database Saves and Deletions in Transactions/Conditional requests. (Documentation) (#108)
- Fixed
TypeError
s when processing certain API exceptions (#295)
- Sent emails can now be localized by providing a
$locale
parameter to the following methods:Kreait\Firebase\Auth::sendEmailVerification($uid, $continueUrl = null, $locale = null)
Kreait\Firebase\Auth::sendPasswordResetEmail($email, $continueUrl = null, $locale = null)
- Improved the error message when encountering an invalid Service Account specification to help developers use the correct one (provided by @puf in this StackOverflow answer)
- When verifying ID tokens, allowed time inconsistencies now include the
auth_time
clime, in addition to theiat
claim. (#278)
- When creating
Kreait\Firebase\Exception\MessagingException
from aGuzzleHttp\Exception\RequestException
, the HTTP response returned was lost.
- Instances of
Kreait\Firebase\Exception\MessagingException
now have better messages (#274).
Kreait\Firebase\Messaging\CloudMessage
: You can now create a new message with a different target from an existing message by using thewithChangedTarget()
method (Documentation).
- The signature of an ID Token is now verified even if a prior error occured (thanks @kanoblake for reporting the issue and providing a test case)
- ID Tokens must have a valid "auth_time" claim.
- Tokens with an invalid signature now throw a
Firebase\Auth\Token\Exception\InvalidSignature
exception. It extends the previously thrownFirebase\Auth\Token\Exception\InvalidToken
, so existing behaviour doesn't change. - Service Account related errors are now more fine grained.
- When loading a non-existing/invalid service account file, error details are now included.
- Database rules are now updated with prettified JSON to improve editing them in the web console.
- Added support for Remote Config Template validation (Documentation)
- Added support for working with the Remote Config History (Documentation)
- When on GCP/GCE, the environment was overriding an explicitely injected service account for API request authentication.
- The SDK can now be used configuration-free on Google Cloud Engine.
Kreait\Firebase\Messaging\CloudMessage
can handle all currently supported types of messages and supersedes the specialized message types.
Kreait\Firebase\Messaging\MessageToTopic::fromArray()
- Use
Kreait\Firebase\Messaging\CloudMessage::fromArray()
- Use
Kreait\Firebase\Messaging\MessageToTopic::create($topic)
- Use
Kreait\Firebase\Messaging\CloudMessage::withTarget('topic', $topic)
- Use
Kreait\Firebase\Messaging\ConditionalMessage::fromArray()
- Use
Kreait\Firebase\Messaging\CloudMessage::fromArray()
- Use
Kreait\Firebase\Messaging\ConditionalMessage::create($condition)
- Use
Kreait\Firebase\Messaging\CloudMessage::withTarget('condition', $condition)
- Use
Kreait\Firebase\Messaging\MessageToRegistrationToken::fromArray()
- Use
Kreait\Firebase\Messaging\CloudMessage::fromArray()
- Use
Kreait\Firebase\Messaging\MessageToRegistrationToken::create($token)
- Use
Kreait\Firebase\Messaging\CloudMessage::withTarget('token', $token)
- Use
- Sanitizing the project ID by default changed the output of the method
\Kreait\Firebase\ServiceAccount::getProjectId()
, so a new method\Kreait\Firebase\ServiceAccount::getSanitizedProjectId()
is now used instead.
- Project IDs that cannot be used for database URIs directly are sanitized when configuring a Service Account (#228)
- When publishing an outdated Remote Config, Firebase previously returned an "OPERATION ABORTED" error,
resulting in a
Kreait\Firebase\Exception\RemoteConfig\OperationAborted
exception. Firebase has changed the error to "VERSION MISMATCH", which now results in aKreait\Firebase\Exception\RemoteConfig\VersionMismatch
exception. The new exception inherits from the old exception, so no code changes are required. - A
Kreait\Firebase\Exception\RemoteConfigException
now includes the full error as returned by the Firebase API.
- Fixed generating a random child key with
$reference->push()->getKey()
(#222) - Fixed deleting a reference by setting it to
null
(#222)
- Added support for setting a continueUrl to email actions (#220, thanks to Wade Womersley)
- Fixed the import of existing Remote Config conditions (#218)
- A more descriptive exception is thrown when adding a parameter to a Remote Config template that refers to a condition that doesn't exist.
- Added support for validating FCM messages without actually sending them (#216) (Documentation)
- Enabled custom configuration and middlewares for the underlying HTTP client (Documentation)
- Fixed issue when creating anonymous users: The Firebase REST API now requires empty payloads to be objects, not arrays (
{}
instead of[]
)
- Added support for non-alphabetical chars in keys in Database snapshots (#212)
- Enabled the caching of Google's public keys used for ID Token verification (#210) (Documentation)
- Added a flag to
Kreait\Firebase\Auth::verifyIdToken()
to ignoreIssuedInTheFuture
exceptions (Documentation)
- Added support for FCM Topic management (Documentation)
Kreait\Firebase\Messaging::subscribeToTopic($topic, $registrationTokens)
Kreait\Firebase\Messaging::unsubscribeFromTopic($topic, $registrationTokens)
- Made
Kreait\Firebase\Factory
extensible so that it can be extended by libraries that want to build on it.- morrislaptop/firestore-php is a new project that aims to
provide support for the Firestore without the need to install the
grpc
PHP extension.
- morrislaptop/firestore-php is a new project that aims to
provide support for the Firestore without the need to install the
- Fixed marking disabled users as enabled when using arrays (#196)
- Added support to unlink identity providers from a user
Kreait\Firebase\Auth::unlinkProvider($uid, $provider)
($provider
can be a string or an array of strings)
- Added support to remove the phone number from a user (#195)
- When you update a user (Documentation), you can now
- set
phoneNumber
tonull
- set
deletePhoneNumber
totrue
- set
deleteProvider
to['phone']
- set
- When you update a user (Documentation), you can now
- Added support for FCM message configurations (Android, APNS, WebPush) (initiated by @Casperhr, thanks!)
- Added support for Firebase Cloud Messaging (Documentation)
- Empty properties in a ProviderData object are now filtered out (e.g. the "phone" provider never includes a photo or an email)
- Added support for setting custom attributes/claims on users
(Documentation,
Official Firebase documentation)
Kreait\Firebase\Auth::setCustomUserAttributes($uid, array $attributes)
- Removed PHP 7.0 incompatible
void
return types
- Added support for the Firebase Remote Config (Documentation)
- Handle non-existing users consistently (#186)
- Fixed setting email verification flags (#183)
- Renamed method with typo
Storage::getFileystem()
to the correctStorage::getFilesystem()
(#182)
- Added support to create and update users with properties
(Documentation)
Kreait\Firebase\Auth::createUser($properties)
Kreait\Firebase\Auth::updateUser($uid, $properties)
- Added
Kreait\Firebase\Auth::getUserByPhoneNumber($phoneNumber)
- Added method to verify the password of an account provided by the email/password provider (Documentation)
Kreait\Firebase\Auth::getUser()
andKreait\Firebase\Auth::getUser()
were throwing a TypeError when trying to create a user record from an empty data set (the Firebase API returns an empty response when no user is found). Now, aKreait\Firebase\Exception\UserNotFound
exception is thrown instead.
Kreait\Firebase\Auth\ApiClient::signupNewUser()
Kreait\Firebase\Auth\ApiClient::enableUser()
Kreait\Firebase\Auth\ApiClient::disableUser()
Kreait\Firebase\Auth\ApiClient::changeUserPassword()
Kreait\Firebase\Auth\ApiClient::changeUserEmail()
Kreait\Firebase\Storage::getFilesystem()
was using/overwriting the configured buckets- Added simple integration test to ensure that file operations work as excpected
- Due to improper caching in the Firebase Factory, configuring a new Firebase instance with another service account would have used a wrongly configured storage.
- Added support for the Firebase Cloud Storage (Documentation)
- Guess incoming timestamps more reliably and ensure UTC Timezones on all returned DateTime properties
- Fix Undefined index "users" while retrieving list of users (#168)
- All deprecated methods and classes have been removed.
Kreait\Firebase\Auth\User
has been replaced withKreait\Firebase\Auth\UserRecord
- All methods that required an instance of
User
now accept UIDs only. - Added methods
Kreait\Firebase\Auth::getUserByEmail(string $email)
- Removed methods
Kreait\Firebase\Auth::getUserByEmailAndPassword()
Kreait\Firebase\Auth::getUserInfo()
Since 4.0, defining authentication overrides is only possible when creating a new Firebase
instance via
the factory (see Authenticate with limited privileges).
Thus, the following methods have been removed:
Kreait\Firebase::asUser()
Kreait\Firebase::asUserWithClaims()
Kreait\Firebase\Database::withCustomAuth()
Kreait\Firebase\Database\ApiClient::withCustomAuth()
The SDK now makes full use of the kreait/firebase-tokens library and throws its exceptions when an ID token is considered invalid.
Also, the option to specify a custom expiration time when creating custom tokens has been removed. Following the official Firebase SDKs, the lifetime of a custom token is one hour.
Added documentation: (Troubleshooting: ID Tokens are issued in the future)
- When deleting a user account, an empty account was created with the same UID (#156)
- Travis CI builds now also work for pull requests
- A Database API Exception did not always include a request (#155)
- Added more integration tests
- Reverted deprecations of
Kreait\Firebase\Factory::withTokenHandler()
and\Kreait\Firebase\Auth\ApiClient::sendEmailVerification()
- Added
Kreait\Firebase\Auth::getUserInfo(string $uid): array
(Documentation) - Added
Kreait\Firebase\Auth::disableUser(string $uid)
(Documentation) - Added
Kreait\Firebase\Auth::enableUser(string $uid)
(Documentation) - Added
Kreait\Firebase\Auth::revokeRefreshTokens(string $uid)
(Documentation) - Added check for revoked ID tokens to
Kreait\Firebase\Auth::verifyIdToken()
(Documentation) - Deprecated the usage of the
Kreait\Firebase\Auth\User
object - Deprecated
Kreait\Firebase\Auth::sendEmailVerification(Kreait\Firebase\Auth\User\User $user)
- Full rewrite of the Authentication documentation
- Bugfix:
Kreait\Firebase\Exception\InvalidIdToken
was not able to hold every invalid ID token (#152)
- Bugfix: Ensure that ID tokens are verified fully and completely (discovered by @hernandev, thanks!)
- Added
Kreait\Firebase\Auth::listUsers(int $maxResults = 1000, int $batchSize = 1000): \Generator
(Documentation) - Auth: Fixed creation of new users (anonymous, email/password)
- Auth: Fixed changing emails and password
- Auth: Removed need for the project's web API key and deprecated related methods
- Added integration tests for database operations
- Restructured tests for clean separation of unit/integration tests
- Enhanced Travis CI build performance
- Ensured support for PHP 7.2
- Fixes bug that not more than one custom token could be created at a time.
- Enable ordering by nested childs (#135)
- When an ID Token verification has failed, the resulting exception now includes the token. (#139, #140)
- Add support for getting and updating Realtime Database Rules (#136) (Documentation)
- Handle non-JSON responses better.
- Restore PHP 7.0 compatibility
- Avoid OutOfBoundsException when a user's email is not set
- Added
Kreait\Firebase\Auth\User::getEmail()
- Added
Kreait\Firebase\Auth\User::hasVerifiedEmail()
- Added
Kreait\Firebase\Auth::sendPasswordResetEmail($userOrEmail)
(Documentation)
- Fixed Travis CI builds for pull requests
- Fixed class/namespace collisions in certain PHP versions.
- Only classes implementing an interface should be final.
- Restored PHP 7.0 compatibility
- Enabled API exceptions to be debuggable by including the sent request and received response. (Documentation)
- Reverted
Kreait\Firebase\Factory
deprecations introduced in 3.2.0
- Added user management features (Documentation)
- Deprecated
Kreait\Firebase\Factory::withServiceAccount()
, useKreait\Firebase\Factory::withServiceAccountAndApiKey()
instead - Deprecated
Kreait\Firebase::asUserWithClaims()
, useKreait\Firebase\Auth::getUser()
andKreait\Firebase::asUser()
instead - Deprecated
Kreait\Firebase::getTokenHandler()
, useKreait\Firebase\Auth::createCustomToken()
andKreait\Firebase\Auth::verifyIdToken()
instead. - Added migration instructions for deprecated methods, see Documentation
- Removed the restriction to the google/auth package to versions <1.0
- Fixed the error that Service Account Autodiscovery was not working when no Discoverer was given.
- Deprecated
Kreait\Firebase\Factory::withCredentials()
(Documentation) - Extracted Service Account discovery to a distinct component (Documentation)
- Added
Kreait\Firebase\ServiceAccount::discover()
- You can now add your own discovery methods (Documentation)
- Added
- Updated and restructured the documentation
- Added additional checks to ensure given credentials are valid and readable
- When using the Factory and passing the path to an invalid credentials file, the factory would continue to try to get the credentials e.g. from one of the environment variables. This has now changed: the factory immediately quits when given invalid credentials.
- When the credentials file has not been found, a
CredentialsNotFound
exception is thrown, including the information which paths have been tried.
- Moved all classes inside the
Kreait
namespace to avoid possible conflicts with official Firebase PHP libraries using theFirebase
namespace. - Removed database secret authentication, as it has been deprecated by Firebase.
Please visit the Migration section in the docs to see which changes in your code are required when upgrading from 2.x to 3.0.
- Fixes the problem that it wasn't possible to use startAt/endAt/equalTo with string values.
- Allow the usage of a custom token handler when creating a new Firebase instance by adding
the factory method
withTokenHandler(\Firebase\Auth\Token\Handler $handler)
- Introduce
Firebase\Factory
to create Firebase instances, and deprecate the previous static instantiation methods on theFirebase
class. It is now possible to omit an explicit JSON credentials file,- if one of the following environment variables is set with the path to the
credentials file:
FIREBASE_CREDENTIALS
GOOGLE_APPLICATION_CREDENTIALS
- or if the file is located at
~/.config/gcloud/application_default_credentials.json
(Linux, MacOS)$APPDATA/gcloud/application_default_credentials.json
(Windows)
- if one of the following environment variables is set with the path to the
credentials file:
- Updated documentation at http://firebase-php.readthedocs.io
- Ensure that
guzzlehttp/psr7
1.4.0 is not used, as it breaks backwards compatibility (see guzzle/psr7#138)
- Updated kreait/firebase-tokens to fix #65 (Invalid token when claims are empty).
- Updated kreait/firebase-tokens to make sure ID token verifications continue to work.
- Added the means to work with custom tokens and ID tokens by using kreait/firebase-tokens. See Authentication: Working with Tokens for usage instructions.
- Replaced the implementation of Database Secret based custom tokens (in the
V2
namespace) with a solution based onlcobucci/jwt
instead of the abandoned firebase/token-generator.
-
Added a
SERVER_TIMESTAMP
constant to theFirebase\Database
class to ease the population of fields with Firebase's timestamp server valueuse Firebase\Database; $ref = $db->getReference('my-ref') ->set('created_at', Database::SERVER_TIMESTAMP);
- Rename "Firebase SDK" to "Firebase Admin SDK for PHP" to emphasize the similarity to the newly introduced official Admin SDKs.
- Added method
Reference::getPath()
to retrieve the full relative path to a node. - Updated docs to make clearer that authenticating with a Database Secret is not recommended since the official deprecation by Firebase (see the "Database Secrets" section in the "Service Accounts" tab of a project )
- It is now possible to pass a JSON string as the Service Account parameter on
Firebase::fromServiceAccount()
. Until now, a string would have been treated as the path to a JSON file.
- First stable release
- 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
- Adds documentation for Version 2.x at http://firebase-php.readthedocs.io/
- Allows the database URI to be overriden when creating a Firebase instance through the factory
- Rewrite, beta status due to missing documentation for the new version.
- The changelog for version 1.x can be found here: https://github.com/kreait/firebase-php/blob/1.x/CHANGELOG.md