1

To verify users for firebase I want to use https://github.com/firebase/firebase-token-generator-php which depends on https://github.com/firebase/php-jwt But how to install? I've checked out both resources in 'libs/firebase-token-generator-php' respectively 'libs/php-jwt'

The problem: "firebase-token-generator-php" uses include_once 'JWT.php'; and that's neither in the same folder nor in my include path.

It would really be easier if I could use composer for that.

2 Answers 2

1

Edit your composer.json as in this example:

{
    "name": "example/firechat",
    "type": "project",
},
"require": {
    "php": ">=5.4",
    "composer/installers": "v1.0.12",
    "firebase/php-jwt": "*",
    "firebase/token-generator": "*"
}

}

Include the libs in your installation, eg:

include_once ABSPATH . 'vendor/autoload.php';

Use the libs in your code, eg:

$tokenGen = new \Services_FirebaseTokenGenerator( "#great-token-from-firebase-app-manager#" );
$token    = $tokenGen->createToken( array( "uid" => 'custom:1'), array( "admin" => true ) );
Sign up to request clarification or add additional context in comments.

Comments

0

Both of these are PEAR packages, so you can download tgz files and install them by PEAR. This way they will be added into your include path.

Other way you have, is to add libs/php-jwt to your include path manually (in ini file or using set_include_path)

2 Comments

Yes I know, but PEAR isn't helpful for me (Cloud based hosting without full server control). I've added the include path, but I think it's not the best method.
You can always fork these repos and add composer.json, remove unnecessary include_once and include forks in your composer.json.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.