kreait / firebase-php

Unofficial Firebase Admin SDK for PHP
https://firebase-php.readthedocs.io/
MIT License
2.26k stars 429 forks source link

ServiceAccount::fromJsonFile() not working #106

Closed setiawanandre06 closed 7 years ago

setiawanandre06 commented 7 years ago

I tried to follow the setup instruction (Manually), and I got this fatal error message:

Fatal error: Uncaught Error: Call to private method Kreait\Firebase\ServiceAccount::fromJsonFile() from context '' in C:\xampp\htdocs\QR-wallet-admin\setup.php:8 Stack trace: #0 {main} thrown in C:\xampp\htdocs\QR-wallet-admin\setup.php on line 8

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(); ?>`

DId I make a wrong path with my 'google-service-account.json'?

dri94 commented 7 years ago

I have this same issue with ServiceAccount::fromJson()

EDIT: The docs just need to be updated it seems. Upgrading the composer.json from "3.0" to "3.1" solved this issue.

setiawanandre06 commented 7 years ago

Oh yeah, right. I just read the docs and It only supports 3.1 version. Thanks!

movdrive commented 6 years ago

Hi guys,

Can you explain me how you solved the problem?

It looks I have the same issue and I can not access correctly the ServiceAccount.

Is there any step-by-step guide on getting a Snapshot from Firebase in PHP?

Best,

jeromegamez commented 6 years ago

There is a usage example at http://firebase-php.readthedocs.io/en/latest/overview.html#usage-example which writes something into the RealtimeDatabase and then fetches it (getValue() is a shortcut for getSnapshot()->getValue()).

Make sure to also require the autoloader (the first line in the code snippet)

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.