1. Go to this page and download the library: Download bluemill/jwt-artisan 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/ */
use GenTux\Jwt\GetsJwtToken;
class CreateUser extends FormRequest
{
use GetsJwtToken;
public function authorize()
{
return $this->jwtToken()->validate();
}
}
use GenTux\Jwt\GetsJwtController;
class FooController extends controller
{
use GetsJwtToken;
public function store()
{
if( ! $this->jwtToken()->validate()) {
return redirect('/nope');
}
...
}
}
use GenTux\Jwt\GetsJwtToken;
class TokenService
{
use GetsJwtToken;
public function getExpires()
{
$payload = $this->jwtPayload(); // shortcut for $this->jwtToken()->payload()
return $payload['exp'];
}
}
use GenTux\Jwt\GetsJwtToken;
class TokenService
{
use GetsJwtToken;
public function getData()
{
// ['exp' => '123', 'context' => ['foo' => 'bar']]
$token = $this->jwtToken();
$token->payload('exp'); // 123
$token->payload('context.foo'); // bar
$token->payload('context.baz'); // null
}
}
use GenTux\Jwt\Exceptions\JwtException;
use GenTux\Jwt\Exceptions\JwtExceptionHandler;
class Handler extends ExceptionHandler
{
use JwtExceptionHandler;
public function render($request, Exception $e)
{
if($e instanceof JwtException) return $this->handleJwtException($e);
...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.