PHP code example of viloveul / auth
1. Go to this page and download the library: Download viloveul/auth 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/ */
viloveul / auth example snippets
$auth = new Viloveul\Auth\Authentication($your_phrase);
$auth->setPrivateKey('private.pem');
$auth->setPublicKey('public.pem');
// create user data
$data = new Viloveul\Auth\UserData([
'id' => 5,
'name' => 'Viloveul',
'email' => '[email protected]'
]);
// get token
$token = $auth->generate($data);
var_dump($token);
// check token
$auth->setToken($token);
$auth->authenticate();
var_dump($auth->getUser());