kreait / laravel-firebase

A Laravel package for the Firebase PHP Admin SDK
https://github.com/kreait/firebase-php
MIT License
1.05k stars 169 forks source link

Manage multiple Firebase configurations within one Laravel app #47

Closed ven0ms99 closed 3 years ago

ven0ms99 commented 4 years ago

Hey there,

for my current project I need the ability to send FCM to hundreds of different apps. However, as far as I can see there is no way to do so with this package, because you can only set one single configuration?

Using the Firebase admin SDK for PHP, it works like this:

$factory = (new Factory)->withServiceAccount('/path/to/firebase_credentials.json');

Take this as a feature request then, thanks!

jeromegamez commented 4 years ago

You're right, at the moment you can only use one Firebase project with the package - it's on my bucket list, but unfortunately, I can't give you an ETA on when I will be able to get to it, and there are a couple of challenges to make it work with Facades and multiple aliases. Thank you for taking the time to tell me that there's an actual need for this!

ven0ms99 commented 4 years ago

I see. So for the moment I have to fallback to the standard Firebase admin SDK for PHP with my Laravel app, right?

Actually I don't even need this feature right now, but I will need it in like 2 months time. Just to let you know, some motiviation 😄 Thank you!

sooxt98 commented 4 years ago

Same here, is there any workaround for this issue? What's the diff using laravel's one v.s. the php one, for me i think the laravel one is just a wrapper but it seems to be more complex when i look into the code. i tried to google but still not sure how to deal with dynamic firebase json config in service provider; I'm planning to store the json into the database, i just need some guide :3

Bonus question: why there's a need to add an extra resolveCredentials func in service provider

jeromegamez commented 4 years ago

The package is indeed just a wrapper, but with helpers that make dependency injection and working "the Laravel way" easier (Facades, Aliases).

It's a general purpose package that is enough for the majority of projects - if you have special requirements (like, at the moment, access to multiple Firebase projects inside one backend application) you're far better off implementing this specifically for your application yourself. The advantage of the current package is that it's easy to set up: one environment variable and you're basically set. This structure would not be well-maintainable with multiple projects.

My recommendation: look at the ServiceProvider of this package to see how it configured the underlying SDK and re-implement it - dynamic configuration with different credentials is far in the future of this package - if it comes at all 🙈

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.