Closed seddighi78 closed 5 years ago
ping @jeromegamez
I already got the notification when you created the issue, no need to ping me one minute after :).
This looks as if the Firebase bundle is not configured for your test environment. Please make sure that it either is configured separately, or that the test config imports the config file in which the bundle is configured.
Oh I'm so sorry - but I'm not in test env my app env is on dev
Ah, I misinterpreted the environment because of the method name, my bad!
Hm... you could try debugging the service container and/or the configuration with the respective Symfony commands.
Besides that, I have no clue without seeing the whole project (but don‘t show it to me 😅)
Have you seen https://github.com/jeromegamez/firebase-php-examples ? You could compare your project/settings to this and see if you spot some differences.
Yes I see the example but it's different from the library documents my configuration file is:
# %kernel.project_dir%/config/packages/firebase/firebase.yaml
kreait_firebase:
projects:
default:
credentials: '%kernel.project_dir%/config/packages/firebase/service_account_key.json'
public: true
alias: 'default'
default: true
Based on the configuration you should be able to get kreait_firebase.default
from the container or (cleaner) inject Kreait\Firebase
as a method dependency.
If this doesn’t work, please debug your container with bin/console debug:container
When I run the command for debugging and search for firebase
i get this result:
$ bin/console debug:container firebase
Select one of the following services to display its information:
[0] Kreait\Firebase\Factory
[1] Kreait\Firebase\Symfony\Bundle\DependencyInjection\Factory\ProjectFactory
>
And if you try $this->get('default');
, does that work?
Still not :(
The issue come from the controller extend class, if you use the deprecated Controller it's work, but with the latest SF4 we need to extend the AbstractController and with this not working.
Reference to fix on latest SF (put it in the repo doc): https://github.com/symfony/symfony-docs/issues/9926
Fix it with:
<?php
namespace App\Controller;
use Kreait\Firebase; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
Now if you extend the new AbstractController it's work, remember to change the key related to your services name's.
As this issue has become stale, I'm closing it now, but please feel free to reopen it.
Still can't inject Kreait\Firebase. Using @nunocodex's proposal returns: "The service "App\Controller\AppController" has a dependency on a non-existent service "Kreait\Firebase"."
The problem
When i calling the service
kreait_firebase
orkreait_firebase.project_name
i get:Environment
kreait/firebase-bundle 1.1.1 kreait/firebase-php 4.16.0 kreait/firebase-tokens 1.7.1 kreait/gcp-metadata 1.0.1 php 7.2.7 symfony 4.1.4
Code to reproduce issue