Comments (15)
In Laravel, you could do for example:
$database = app('firebase.firestore')->database();
$var_list = $database->collection('tokens')->document('tokens')->snapshot();
from laravel-firebase.
If youβre satisfied with the outcome, of course :). Please fell free to create a new issue or ask on Discord if you have further questions!
from laravel-firebase.
Today I suddenly got this issue after run config:cache then I figured out that it only read FIREBASE CREDENTIALS in .env not GOOGLE_APPLICATION_CREDENTIALS
from laravel-firebase.
Hm, this looks like if perhaps the composer autoloader has lost some information - could you try doing a composer dumpautoload
and see if that fixes something? And ensure that your credentials file is really unchanged?
I'm just guessing, but the error hints at the project ID not being available, and the project ID is always included in the service account JSON.
from laravel-firebase.
Thank you for your prompt reply.
Since an exception was found in Discover.php
, I started running after clearing the cache.
Kreait\Firebase\ServiceAccount\Discovery\FromEnvironmentVariable: The environment variable "FIREBASE_CREDENTIALS" is not set.
Kreait\Firebase\ServiceAccount\Discovery\FromEnvironmentVariable: The environment variable "GOOGLE_APPLICATION_CREDENTIALS" is not set.
Kreait\Firebase\ServiceAccount\Discovery\FromGoogleWellKnownFile: The well known file is not readable or invalid
cURL error 6: Could not resolve host: metadata.google.internal (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
We are now thinking about how to respond.
Is there a way to load firebase_credential.json
without using Discover.php
when doing new Factory ()
?
from laravel-firebase.
I tried $factory = (new Factory())->withServiceAccount('/var/www/server/firebase.json');;
And FIREBASE_CREDENTIALS
key is not set.
The process is end, nothing error.
Is this the way it is?
from laravel-firebase.
That's the way it is, yes. As soon as you provide a service account, the factory will not try to auto-discover the credentials after that.
You are not receiving the error in that line, the most common reason for this error is that you are not using the same factory that you initialized. As an example:
$factory = (new Factory())->withServiceAccount('...');
Here, the second line will return a new instance of the factory, the previous `$factory` will be untouched
$factory->withDatabaseUrl('...');
// Correct would have been
$factory = $factory->withDatabaseUrl('...');
from laravel-firebase.
Hi, Kreait Team.
Thank you.
With your advice, my project was able to move on.
Thanks for the quick reply and courteous response.
from laravel-firebase.
Oh, I just realized that we are in the context of the Laravel Package π - here you normally shouldn't need to invoke the Factory manually at all.
Could you tell me more about why you are doing new Factory()
instead of using app('firebase.<component>')
or dependency injection?
from laravel-firebase.
I saw this page and wrote the program.
https://firebase-php.readthedocs.io/en/stable/cloud-firestore.html
Now, when I reviewed Readme.md again, it was written. I missed it without noticing.
I will try again!
from laravel-firebase.
Hi, jeromegamez.
The program I wrote now looks like.
use Kreait\Firebase;
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Firebase\Messaging\Notification;
use Kreait\Firebase\Messaging\WebPushConfig;
// This code is get Cloud Firestore collections.
$factory = (new Factory())->withServiceAccount(config('firebase.config'));
$firestore = $factory->createFirestore();
$database = $firestore->database();
$var_list = $database->collection('tokens')->document('tokens')->snapshot();
How can I write this in a form suitable for Laravel without using "new factory ()"?
I am glad that it is also an example to be helpful.
from laravel-firebase.
Thank you for your reply.
I tried as you say and it was successful.
Thanks for the quick response.
It was not a problem with your library.
Can I close this issue?
from laravel-firebase.
The behaviour should be that it first tries to read from FIREBASE_CREDENTIALS
and from GOOGLE_APPLICATION_CREDENTIALS
if the former is not set. If both are set, FIREBASE_CREDENTIALS
take precedence, even if it's set with an empty value. (
laravel-firebase/config/firebase.php
Line 50 in d5b468f
from laravel-firebase.
today I have same problem after I ran php artisan config:cache.
After I ran: php artisan config:clear
Problem solve.
from laravel-firebase.
For anyone who comes after me, I had this issue when using google/cloud-firestore
directly. I created a FirestoreServiceProvider
which registered a singleton, but I failed to register the service provider in config/app.php
from laravel-firebase.
Related Issues (20)
- Callable functions
- SenderId mismatch HOT 7
- Laravel error HOT 2
- getting error HOT 1
- Incompatibility with Eloquent Resources? HOT 1
- Confirm email verification Support
- Its not supported php 8. Please fix this
- Push notifications are not getting displayed in IOS and Android randomly HOT 1
- Be able to override FirestoreClient::DEFAULT_DATABASE HOT 7
- Support PHP8.3 HOT 2
- Firestore insert or update problem when using laravel-octane HOT 3
- Auto discovery not working similar to v4.x HOT 6
- Cannot mock final class for phpunit tests as it's return type is other final class HOT 1
- Support symfony/cache version 7 HOT 3
- Make Support For Laravel 11 HOT 2
- Curl error on Laravel 11 HOT 9
- laravel publish issue HOT 1
- Unable to install kreait/laravel-firebase on Laravel 11 project HOT 1
- Binding Error with 5.9 HOT 2
- Log Channel Not Working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-firebase.