Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrandyn Lordi
17,778 PointsWhy is this JWT array value wrapped in curly braces?
the 'Sub' below-
$jwt = \Firebase\JWT\JWT::encode([
'iss' => request()->getBaseUrl(),
'sub' => "{$user['id']}",
'exp' => $expTime,
'iat' => time(),
'nbf' => time(),
'is_admin' => $user['role'] == 1
], getenv('SECRET_KEY'), 'HS256');
1 Answer
Chris Shaw
26,676 PointsHi Brandyn Lordi,
I would recommend you have a read of the link below which explains in some degree of detail what JWT is and how they work.
Hope that helps!
Brandyn Lordi
17,778 PointsBrandyn Lordi
17,778 PointsHi Chris, Thanks for your reply.
Perhaps I missed something, but the curly braces around the subject don't appear unique to creating the JWT, at least- not from what I could tell in the docs (which leave much to be desired IMO).
I still don't understand the purpose of the curly braces around the value of 'sub' when creating the JWT for these specific videos in this project.