Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create the messaging service #65

Closed
jernejbeg opened this issue Oct 19, 2020 · 3 comments
Closed

Unable to create the messaging service #65

jernejbeg opened this issue Oct 19, 2020 · 3 comments

Comments

@jernejbeg
Copy link

jernejbeg commented Oct 19, 2020

Hi, I am getting the following runtime exception when I do a composer install:

Unable to create the messaging service without a project ID at vendor/kreait/firebase-php/src/Firebase/Factory.php:467

 public function createMessaging(): Messaging
 {
      if (!($projectId = $this->getProjectId())) {
             throw new RuntimeException('Unable to create the messaging service without a project ID');
  }

$messagingApiClient = new Messaging\ApiClient(

$this->createApiClient([

+33 vendor frames

I am using dependency injection in my service class and I have the config set up properly in my env file.

This happens every time I try to do a composer install on other machines (the initial setup went fine). If I remove the code, do a composer install it passes and installs the packages as expected. What could I be doing wrong?

@jeromegamez
Copy link
Member

Sorry for the late reply! I haven't encountered this error so far, especially not during a composer install. I just tried this myself with a fresh install and unfortunately wasn't able to reproduce the problem.

In the meantime, version 3.0 of the package was released, could you please check if the problem exists with it as well (unless you're already using it).

The only thing I could guess at the moment is that the FIREBASE_CREDENTIALS is set with an empty value (e.g. with FIREBASE_CREDENTIALS= in the .env file) and that the SDK is instantiated before being available. 🤔

@jernejbeg
Copy link
Author

@jeromegamez no problem at all. Maybe you can try the following... create a fresh project and make two branches. The first one can be a plain Laravel installation. After that make a new branch and install the plugin (also make a dummy service). Then switch back to the plain Laravel branch and do a composer install. In this case, the installation should fail and produce a reported problem.

I managed to solve this issue by manually deleting the cache in both the bootstrap and storage directories. Hope we can find where the issue comes from.

@qazny
Copy link

qazny commented Nov 19, 2020

Hi, I also experienced this issue. Reason may be that when config was cached, application does not have access to env variables directly (as far as I understand). In this case, script cannot get the path to the file from env. I solved this problem by adding $factory = $factory->withServiceAccount(config('firebase.projects.app.credentials.file'));.
Script should also try to get path to credentials from config in Firebase/Factory@getServiceAccount.

@jeromegamez jeromegamez closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants