You could use lexik/jwt package provided by symfony.
Run the following commands in order:
php composer.phar require "lexik/jwt-authentication-bundle" (install the package)bin/console lexik:jwt:generate-keypair (generate keys)Here is the symfony docs for more info: https://symfony.com/bundles/LexikJWTAuthenticationBundle/current/index.html