1. Go to this page and download the library: Download tangoman/jwt-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tangoman / jwt-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = array(
// ...
new TangoMan\JWTBundle\TangoManJWTBundle(),
);
// ...
}
}
// AppBundle/Controller/SecurityController.php
use TangoMan\JWTBundle\Model\JWT;
// Get service
$jwtService = $this->get('tangoman_jwt');
// Instantiate new JWT model
$jwt = new JWT();
$jwt->set('email', '[email protected]');
$jwt->set('username', 'Admin');
$jwt->setPeriod(new \DateTime(), new \DateTime('+3 days'));
// Encode token
$token = $jwtService->encode($jwt);