PHP code example of daycry / jwt

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

    

daycry / jwt example snippets


$psr4 = [
    'Config'      => APPPATH . 'Config',
    APP_NAMESPACE => APPPATH,
    'App'         => APPPATH,
    'Daycry\JWT' => APPPATH .'ThirdParty/JWT/src',
];

 

$library = new \Daycry\JWT\JWT();
$encode = $this->library->encode('hello');



$config = config('JWT');
$library = new \Daycry\JWT\JWT($config);
$encode = $this->library->encode('hello');

$decode = $this->library->decode($encode);

$decode->get('data');



$config = config('JWT');
$library = (new \Daycry\JWT\JWT($config))->setParamData('another');
$encode = $this->library->encode('hello');

$decode = $this->library->decode($encode);

$decode->get('another');



$config = config('JWT');
$library = (new \Daycry\JWT\JWT($config))->setParamData('another');
$encode = $this->library->encode(array( 'first' => '1', 'second' => '2' ));

$decode = $this->library->decode($encode);

\json_decode($decode->get('another'));



$config = config('JWT');
$library = (new \Daycry\JWT\JWT($config))->setSplitData();
$encode = $this->library->encode(array( 'first' => '1', 'second' => '2' ));

$decode = $this->library->decode($encode);

$decode->get('first');
$decode->get('second');