php - Message: Call to private method KreaitFirebaseServiceAccount::fromJsonFile() from context 'Firebase'
one text
Solution:
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)
->withServiceAccount($serviceAccount)
->create();
$database = $firebase->getDatabase();
Change it to the following:
use Kreait\Firebase\Factory;
$factory = (new Factory)->withServiceAccount(__DIR__.'/google-service-account.json');
$database = $factory->createDatabase();
Source