PHP code example of anhpha / lexik-jwt-service-provider

1. Go to this page and download the library: Download anhpha/lexik-jwt-service-provider 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/ */

    

anhpha / lexik-jwt-service-provider example snippets


  $ttl = 86400;
        $exp = time() + $ttl;
        $token = $this->container['lexikEncoder']()->encode(['username' => 'test', 'exp' => $exp]);
        $response = new JsonResponse();
        $response->setData(array(
            'token' => $token,
        ));
        //$response = new JsonResponse();
        return $response;