Note the below examples are just for guidance - you are free to use any JWT library you are comfortable with or which your frameworks support. As you can see on the official JWT site - there are plenty of available libraries for each possible language.
The Java example is using the popular open source java-jwtlibrary.
The PHP example doesn't use external libraries, so it is a little bit more verbose.