1. Go to this page and download the library: Download equites/core 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 Core\\Controller;
class Users extends Controller\\Json
{
public function GET()
{
// Will be encoded to {"ok":true,"time":1699999999}
return ['ok' => true, 'time' => time()];
}
public function POST()
{
// You can also return a pre-encoded string if you need custom options
return json_encode(['ok' => true], JSON_PRETTY_PRINT);
}
}
use Core\\DB;
$pdo = DB::get();
$stmt = $pdo->prepare('SELECT * FROM users WHERE id = :id');
$stmt->execute(['id' => 1]);
$row = $stmt->fetch();
use Core\\Vault;
$vault = Vault::getInstance();
$vault->set('userId', 123);
$vault->set('traceId', bin2hex(random_bytes(8)));
// Later in the same request
$userId = $vault->get('userId'); // 123
$vault->unset('traceId'); // remove single key
// Optionally clear everything at end of request
$vault->clear();