Currently I want to implement firebase/php-jwt into laravel 5
I've run the command composer require firebase/php-jwt under my laravel 5 project, and I get
"require": {
    ...
    "firebase/php-jwt": "^3.0"
},
in package.json
from config/app.php, I need inject this library, but don't know how to do.
use tymondesigns/jwt-auth instead, 
and follow JSON Web Token Tutorial: An Example in Laravel and AngularJS
Eventhough your front-end not using angular, it doesn't matter
After installing it via composer then
Add these two lines to your app.php
'J42\LaravelFirebase\LaravelFirebaseServiceProvider',
and
'Firebase'        => 'J42\LaravelFirebase\LaravelFirebaseFacade'
Also don't forget to add the credentials in your config/database.php
Tip 1 :
You shall with the basic requests like Firebase::get('/my/path');
Here's the good resource to have a start with
Tip 2 : Here is the beautiful resource that you shall refer.
It's is resolved in version 5 as follow: Assuming you have it from composer
    "require": {
        ...
        "firebase/php-jwt": "^5.0",
    },
Then you just call this in your class:
use Firebase\JWT\JWT;
...
protected function generateJwt(){
        if (config('jwt.secret')) {
            $now_seconds = time();
            $payload = array(
                    "iss" => ...,
                    "sub" => ...,
                    "aud" => ...,
                    "iat" => $now_seconds,
                    "exp" => $now_seconds + 60*60,  // Maximum expiration time is one hour
            );
            $this->jwt = JWT::encode($payload, config('jwt.secret'), "HS256");
        }
        Log::error("Missing JWT_SECRET in .env");
    }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With