kreait / firebase-tokens-php

A PHP library to work with Firebase tokens
MIT License
223 stars 33 forks source link

'Lcobucci\JWT\Signer\Key\InMemory' not found #38

Closed yacineblr closed 3 years ago

yacineblr commented 3 years ago

Hi, I just installed the lib with composer and I have a problem with the lib "Lcobucci/JWT".

Error:

Fatal error: Uncaught Error: Class 'Lcobucci\JWT\Signer\Key\InMemory' not found in /wp-content/plugins/myplugin/Firebase/vendor/kreait/firebase-tokens/src/Firebase/Auth/Token/Generator.php on line 38

My composer

    "minimum-stability": "dev",
    "require": {
        "kreait/firebase-php": "^5.19",
        "kreait/firebase-tokens": "^1.15"
    }

My php file

  use Kreait\Firebase\Factory;
  use  Kreait\Firebase\Auth;

  $factory = (new Factory)->withServiceAccount(__DIR__ . '/google-service.json);

  $auth = $factory->createAuth();

Do you know what the error is, please ?

jeromegamez commented 3 years ago

The error indicates that a required class cannot be found (Lcobucci\JWT\Signer\Key\InMemory). This could have many reasons:

You can check what is installed by running composer show and see which version of the kreait and lcobucci/jwt libraries are installed. lcobucci/jwt should be a version greater than 3.4.1, kreait/firebase-php should currently be greater than 5.20.1 and kreait/firebase-tokens should be ^1.15.

I don't know how composer behaves in the context of a Wordpress project / Wordpress plugin (I've seen it in a file path of your original post), so I'm afraid I can't help with that.

yacineblr commented 3 years ago

Composer log after "composer installl":

  Problem 1
    - kreait/firebase-php[5.20.1, ..., 5.x-dev] require php ^7.4|^8.0 -> your php version (7.3.11) does not satisfy that requirement.
    - Root composer.json requires kreait/firebase-php ^5.20.1 -> satisfiable by kreait/firebase-php[5.20.1, 5.x-dev].

It was a problem with my PHP version (7.3.11) of "compose". It was installing "kreait/firebase-php" in version 5.19 and not the latest "5.20.1".

Thanks to the fact that you told me the version number, I solved the problem

jeromegamez commented 3 years ago

Glad that you came to a solution, and thank you for sharing it here - I'm sure others in a similar situation will benefit from it! 🙏