The code you posted is from kreait/firebase-php and shows a private method from the ServiceAccount class that can not be called directly since release 5.0 of the SDK.

Straight from the troubleshooting section in the documentation:

You probably followed a tutorial article or video targeted at a 4.x version, and your code looks like this:

use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;

$serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/google-service-account.json');
$firebase = (new Factory)

$database = $firebase->getDatabase();

Change it to the following:

use Kreait\Firebase\Factory;

$factory = (new Factory)->withServiceAccount(__DIR__.'/google-service-account.json');

$database = $factory->createDatabase();

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top