All SDKs

PHP SDK

One file, no required extensions.

v1.1.0PHP 8.1+

Install

terminal
curl -o Warden.php https://wardenauth.dev/packages/php/1.1.0/Warden.php

PHP 8.1+, no extensions required. HTTPS API URLs need ext-openssl or ext-curl enabled.

  • Signatures use ext-sodium when it's loaded, otherwise a built-in verifier on GMP or bcmath, so a stock PHP install works.
  • On Windows, enable HTTPS by adding extension=openssl to php.ini.
  • In a web app, keep $app->sessionId in $_SESSION so each page load reuses one Warden session instead of calling init() again.

The URL includes the version, and released versions never change, so a pinned install keeps working. See the changelog for older versions.

Quickstart

Replace the placeholders with your app's values from its Overview in the dashboard, where the Add Warden to your project card shows this snippet with your credentials already filled in. The application ID and public key are safe to ship; never put your seller key in client code.

main.php
<?php
require_once __DIR__ . '/Warden.php';

$app = new Warden\Client(
    'YOUR_APP_ID',
    'YOUR_PUBLIC_KEY',
    '1.0',
    'https://wardenauth.dev/api/v1',
);

try {
    $app->init();
    $user = $app->license(readline('License key: '));
    echo "Welcome {$user->username}!\n";
} catch (Warden\WardenException $e) {
    echo $e->getMessage(), "\n";
}

Example project

A complete program with the usual loader menu (login, register, upgrade, key-only login) that prints the user's details. It bundles the SDK, so it runs without installing anything. Fill in the Application credentials block and put your code where it says Your application code goes here.

Edit
main.php
Run
php main.php
Needs
PHP 8.1+
Download the PHP example

API

Every method maps to one call of the client API. Each response is checked against your public key, timestamp and nonce before the SDK uses it.

MethodWhat it does
$app->init(…)Start a session. Call this first.
$app->login(…)Log in with a username and password.
$app->register(…)Create an account by redeeming a license key.
$app->license(…)Log in with just a license key.
$app->upgrade(…)Redeem another key on an existing account.
$app->check(…)Whether the session is still logged in.
$app->checkBlacklist(…)Whether this machine's IP or HWID is blacklisted.
$app->var(…)Read a global variable.
$app->getVar(…)Read one of the user's variables.
$app->setVar(…)Write one of the user's variables.
$app->file(…)Download a file into memory.
$app->webhook(…)Call one of your webhooks through the server.
$app->log(…)Send a log line to your dashboard.
$app->ban(…)Ban the current user (e.g. after detecting a debugger).
$app->fetchOnline(…)Usernames with a logged-in session.
$app->fetchStats(…)User, online and key counts.
$app->chatGet(…)The last 50 messages in a channel.
$app->chatSend(…)Post to a channel.
$app->logout(…)End the session.

Errors

Failures throw Warden\WardenException; $e->response holds the server's reply when it rejected the request.

Rejected responses, including a bad signature, a stale timestamp or a replayed nonce, fail the same way, so a spoofed server can't log anyone in. See verifying responses, and protecting your app for what a signature check can and can't stop.