firebase-php: Fatal error during initialization of auth object
Describe the bug Hi, I ran into a error during initialization of the auth object. This error comes up:
Fatal error: Declaration of Kreait\Firebase\Auth\ApiClient::request($method, $uri, array $options = Array): Psr\Http\Message\ResponseInterface must be compatible with GuzzleHttp\ClientInterface::request(string $method, $uri, array $options = Array): Psr\Http\Message\ResponseInterface in {path}/libs/vendor/kreait/firebase-php/src/Firebase/Auth/ApiClient.php on line 25
To Reproduce I followed the tutorial in the documentation here step by step.
I downloaded the composer. Then I used it to download this set of libraries. I moved the created directories through ftp onto the server. There I tried to run this code and I got the error.
require "../libs/vendor/autoload.php";
use Kreait\Firebase\Factory;
use Kreait\Firebase\Auth\Token\Exception\InvalidToken;
use Kreait\Firebase\ServiceAccount;
if(isset($_POST['idTokenString'])) {
$idTokenString = $_POST['idTokenString'];
//create Firebase factory object
$factory = (new Factory())->withServiceAccount('../privatekey.json');
$auth = $factory->createAuth(); //this line makes the error
}
Expected behavior It should run without an error.
Environment (please complete the following information):
- OS: Windows 10
- PHP version: 7.1.33-15+0~20200419.36+debian8~1.gbp2384b3
- Firebase SDK Version: 5.7
Other info Sorry if this isn’t the place where to place error, but I don’t know where else to post it. Thanks for help in advance.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (10 by maintainers)
As @isteiger said, the 5.x releases of the SDK require at least PHP 7.2 to run. If you’re stuck with PHP 7.1, you will need a 4.x release.
You can downgrade by changing the version constraint in your
composer.json:Please keep in mind that the 4.x releases have not all the features that the 5.x releases have - you can find the documentation for version 4.44 at https://firebase-php.readthedocs.io/en/4.44.0/index.html
PHP 7.1 has reached its end of life in 2019 (it doesn’t receive bugfixes or security fixes anymore), I strongly recommend upgrading to a newer version, preferably PHP 7.4.
please use PHP 7.2 or up to ensure no errors occur