I am using firebase as backend in php, but when i am calling "fromJsonFile" method of "ServiceAccount" i am getting bellow error:
Fatal error: Uncaught Error: Call to private method Kreait\Firebase\ServiceAccount::fromJsonFile() from context '' in C:\xampp\htdocs\wordpress\wp-content\plugins\firebase-connection.php:7 Stack trace: #0 C:\xampp\htdocs\wordpress\wp-content\plugins\sb-api\sb_api.php(31): include() #1 C:\xampp\htdocs\wordpress\wp-settings.php(362): include_once('C:\xampp\htdocs...') #2 C:\xampp\htdocs\wordpress\wp-config.php(90): require_once('C:\xampp\htdocs...') #3 C:\xampp\htdocs\wordpress\wp-load.php(37): require_once('C:\xampp\htdocs...') #4 C:\xampp\htdocs\wordpress\wp-admin\admin.php(34): require_once('C:\xampp\htdocs...') #5 C:\xampp\htdocs\wordpress\wp-admin\index.php(10): require_once('C:\xampp\htdocs...') #6 {main} thrown in C:\xampp\htdocs\wordpress\wp-content\plugins\firebase-connection.php on line 7
The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.
Here is my code:
<?php
require __DIR__.'/vendor/autoload.php';
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();
?>