Hello i am trying to make connection to firebase database from php and i have this code
<?php
require __DIR__.'/vendor/autoload.php';
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__ . '/secret/sajilo-entrance-med-firebase-adminsdk-1bta4-487ebfe276.json');
$factory = (new Factory)->withServiceAccount($serviceAccount);
$firebase = (new Factory)
->withServiceAccount('$serviceAccount')
->withDatabaseUri('https://sajilo-entrance-med.firebaseio.com/')
->create();
$database = $firebase->getDatabase();
?>
and i am getting this error
Fatal error: Uncaught TypeError: Argument 1 passed to Kreait\Firebase\Factory::withServiceAccount() must be an instance of Kreait\Firebase\ServiceAccount, string given, called in C:\xampp\htdocs\MedEntrance\dbconfig.php on line 10 and defined in C:\xampp\htdocs\MedEntrance\vendor\kreait\firebase-php\src\Firebase\Factory.php:77 Stack trace: #0 C:\xampp\htdocs\MedEntrance\dbconfig.php(10): Kreait\Firebase\Factory->withServiceAccount('$serviceAccount') #1 C:\xampp\htdocs\MedEntrance\insert_test.php(43): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\MedEntrance\vendor\kreait\firebase-php\src\Firebase\Factory.php on line 77
$serviceAccountcontains? It seems to be a string whileFactory::withServiceAccount()expects an instance of theServiceAccountclass. - M. Eriksson