PHP-JWT eklentisi:https://github.com/lcobucci/jwt
Klein.php router: https://github.com/klein/klein.php
Laravel ile yazılmış örnek: https://github.com/sahat/satellizer/...Controller.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
$klein = new \Klein\Klein();
use Lcobucci\JWT\Builder;
$token = (new Builder())->setIssuer('http://example.com') // Configures the issuer (iss claim)
->setAudience('http://example.org') // Configures the audience (aud claim)
->setId('4f1g23a12aa', true) // Configures the id (jti claim), replicating as a header item
->setIssuedAt(time()) // Configures the time that the token was issue (iat claim)
->setNotBefore(time() + 60) // Configures the time that the token can be used (nbf claim)
->setExpiration(time() + 3600) // Configures the expiration time of the token (nbf claim)
->set('uid', 1) // Configures a new claim, called "uid"
->getToken(); // Retrieves the generated token
$klein->respond('POST', '/auth/login', function($request, $response){
$req = $request->body();
$data = json_decode($req);
$email = $data->email;
$gecPassword = $data->password;
});
$klein->dispatch();