Git Product home page Git Product logo

Comments (21)

jeromegamez avatar jeromegamez commented on June 24, 2024 3

@chimit @ulver2812 Could you please try the two following alternatives?

'credentials' => [
    'file' => base_path().DIRECTORY_SEPARATOR.env('FIREBASE_CREDENTIALS'),
],

or

'credentials' => [
    'file' => base_path(env('FIREBASE_CREDENTIALS'))
],

Please also make sure that, if on Windows, you use \\ instead of / in your .env file, I think otherwise the paths will not be resolved

from laravel-firebase.

chimit avatar chimit commented on June 24, 2024 1

Ah, sorry! My mistake! Just realized that I forgot to apply config in the bootstrap/app.php (Lumen):

$app->configure('firebase');

So yes, this config works:

'credentials' => [
        'file' => base_path(env('FIREBASE_CREDENTIALS')),

from laravel-firebase.

eluar avatar eluar commented on June 24, 2024 1

If somebody of you guys is still having this issue in Laravel 5.8. You can use the php function realpath to do the following in the config/firebase.php file:

'credentials' => [
        // For this example the FIREBASE_CREDENTIALS_FILENAME is in the project 's root folder
        'file' => realpath('.' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . env('FIREBASE_CREDENTIALS_FILENAME')),
        'auto_discovery' => true,
    ],

from laravel-firebase.

ulver2812 avatar ulver2812 commented on June 24, 2024

Possible solution is to use base_path() in the config file:

'credentials' => [
        'file' => base_path() . '/' . env('FIREBASE_CREDENTIALS'),
        'auto_discovery' => true,
    ],

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

Sorry for the late reply! This is probably something that I should investigate in the main SDK - it seems to be a Windows issue, I just tried it with a relative path like yours, and it works on my machine(™).

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

After having begun to implement GitHub Actions, I can now confirm the issue 🎉 (see e.g. https://github.com/kreait/firebase-php/runs/378003314). As soon as I have finished the GitHub Actions setup, I will look for a way to fix the problem. 🤞

Update: I can confirm that there is an issue 😅, it's not the same as you described :)

from laravel-firebase.

chimit avatar chimit commented on June 24, 2024

Modifying the config file doesn't help. Currently, the only way to make it work is to specify the full path in the .env file.

from laravel-firebase.

chimit avatar chimit commented on June 24, 2024

Both don't work. Apparently, this credentials.file parameter is just ignored.

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

It's not - (or) have you step-debugged the package's service provider to be able to see what the issue is/that this is the issue?

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

@chimit Yessss 🎉 - can I assume that you are currently using the branch that I gave you in #8? Asking for a friend who would then create a new release 😅

from laravel-firebase.

chimit avatar chimit commented on June 24, 2024

Yes, apparently, it's working with Lumen 6.3. Just want to finish push notifications to make sure there are no other problems. Will confirm it separately on that issue page.

Thanks a lot! 👍

from laravel-firebase.

ulver2812 avatar ulver2812 commented on June 24, 2024

Hi @jeromegamez, sorry for the late reply (I didn't receive the github notification).
My current fix is this:

Possible solution is to use base_path() in the config file:

'credentials' => [
        'file' => base_path() . '/' . env('FIREBASE_CREDENTIALS'),
        'auto_discovery' => true,
    ],

On Windows it works, I didn't investigate further...

from laravel-firebase.

chimit avatar chimit commented on June 24, 2024

@ulver2812 I updated Lumen instructions (#11). Do we need to add base_path() into the config/firebase.php now?

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

Unfortunately, it's not as easy. base_path() would break things if a full path is provided (like /full/path/to/service_account.json or C:\\full\path\to\service_account.json), it would only work for relative paths.

So, while this might work on your local machine, where you put the service account file in the project directory, it might break on a production machine where the file could be outside the project directory. Also, on one machine you could be on Windows, on the other on Linux... I'll try to come up with something, but I need it to be a stable solution 😅

from laravel-firebase.

ulver2812 avatar ulver2812 commented on June 24, 2024

So, at the end the best thing to do is to use absolute paths 🤷‍♂️

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

Could you please check out and try #13 to see if this works for you on Windows?

from laravel-firebase.

ulver2812 avatar ulver2812 commented on June 24, 2024

Sorry but I can't check right now, I will try as soon as possible. Thanks

from laravel-firebase.

chimit avatar chimit commented on June 24, 2024

Using absolute paths is not very convenient when you deploy your project to many environments or change them. As for me, a relative path should be a default.

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

@chimit Could you please test if #13 works for you?

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

It's been long enough, I will merge #13 and if something doesn't work, someone will let me know for sure :)

from laravel-firebase.

jeromegamez avatar jeromegamez commented on June 24, 2024

Merged with 3213acc, released with 1.4.0

from laravel-firebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.