PHP code example of padcmoi / bundle-api-slim
1. Go to this page and download the library: Download padcmoi/bundle-api-slim 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/ */
padcmoi / bundle-api-slim example snippets
use Padcmoi\BundleApiSlim\Database;
use Padcmoi\BundleApiSlim\Misc;
use Padcmoi\BundleApiSlim\SanitizeData;
use Padcmoi\BundleApiSlim\Token\JwtToken;
// database
$lastInsertId = Database::insert(
"INSERT INTO `__tokens` SET
`payload` = md5(:payload),
`header` = 'jwt',
`uid` = :uid,
`not_before_renew` = DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL :nbf SECOND),
`expire_at` = DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL :exp SECOND)",
array(':payload' => $serializedToken, ':uid' => $uid, ':nbf' => $nbf, ':exp' => $expire)
);
// ...
// auth token
$jwt_token = JwtToken::create();
$uid = JwtToken::getUid($jwt_token);
var_dump(JwtToken::check($jwt_token));
SanitizeData::without(['ab', 'baa', 'aa']);
SanitizeData::clean(true, []);
Misc::snakeCase('aze ert uUu . tt.oo__aa//jjj;içp');
// Use only JWT
use Padcmoi\BundleApiSlim\Token\SimplyJWT;
SimplyJWT::init('***PRIVATE_KEY***', 'HS256', 3600); // KEY, Algorithm, Expire Timestamp
$serializedToken = SimplyJWT::encode([
"exp" => time() + 3600,
"iat" => time(),
"uid" => -1, // Id account
]);
$payload = SimplyJWT::decode($serializedToken);