laravel-firebase: No such file or directory for service account json
Hi, I’m trying to use this package but I get this error:
Kreait\Firebase\Exception\InvalidArgumentException
google-service-account.json can not be read: SplFileObject::__construct(google-service-account.json):
failed to open stream: No such file or directory
I set the firebase service account json path in the env file in this way
FIREBASE_CREDENTIALS=google-service-account.json
and
FIREBASE_CREDENTIALS=/google-service-account.json
but it doesn’t work, I’m trying to run this code in a HTTP Controller class
FirebaseAuth::listUsers();
The google-service-account.json file is in the Laravel project root folder along with composer.json etc.
What’s the issue ? Thanks
UPDATE: I’m on windows 10 and if I give the full path like so
FIREBASE_CREDENTIALS="C:\\xampp\\htdocs\\my-laravel-app\\google-service-account.json"
It works, how do I make it work with relative path ?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 21 (10 by maintainers)
@chimit @ulver2812 Could you please try the two following alternatives?
or
Please also make sure that, if on Windows, you use
\\instead of/in your.envfile, I think otherwise the paths will not be resolvedIf somebody of you guys is still having this issue in Laravel 5.8. You can use the php function
realpathto do the following in theconfig/firebase.phpfile:Ah, sorry! My mistake! Just realized that I forgot to apply config in the
bootstrap/app.php(Lumen):So yes, this config works: