A complete, ready-to-use PHP integration example for the AuthVaultix authentication platform.
This repository provides a plug-and-play PHP example demonstrating how to integrate the AuthVaultix authentication API into your PHP web application. It includes:
- π Login β Authenticate users with username & password (+ optional 2FA)
- π Register β Create new accounts with a license key
- π License Login β Access the app using only a license key
- π Dashboard β A protected page that displays user session info, subscriptions & expiry dates
- πͺ Logout β Securely terminate sessions via the API
Built with a modern, responsive UI using Tailwind CSS and Inter font β looks great on all screen sizes.
authvaultix-php-example/
βββ index.php # Login / Register / License page (public)
βββ authvaultix.php # AuthVaultix PHP API wrapper (core library)
βββ credentials.php # Parses .env and sets up credentials
βββ .env # Your app credentials (name, ownerid, secret, version)
βββ logo.webp # Local app logo to bypass hotlink protection
βββ dashboard/
βββ index.php # Protected dashboard (requires authentication)
- PHP 7.4 or higher
curlPHP extension enabled- A web server (Apache / Nginx) or PHP's built-in server
- An AuthVaultix account β Register here
git clone https://github.com/AuthVaultix/AuthVaultix-PHP-Example.git
cd AuthVaultix-PHP-ExampleCreate a .env file in the root directory and fill in your application details from the AuthVaultix Dashboard:
APP_NAME=YourAppName
OWNER_ID=your_owner_id
SECRET=your_secret
VERSION=your_version
β οΈ Never commit real credentials to a public repository.
Add.envto your.gitignorefile.
php -S localhost/[Project-name]Then open http://localhost/[Project-name] in your browser. & you can use XAMP server too. XAMP server location is C:/xampp/htdocs. Copy the project folder to the htdocs folder & run http://localhost/[Project-name]/ in your browser.
The authvaultix.php file contains the AuthVaultix\api class. Here's how to use it in your own project:
<?php
include 'authvaultix.php';
include 'credentials.php';
$app = new AuthVaultix\AuthVaultixClient($name, $ownerid, $secret, $version);
$app->init(); // Must be called before any other method$success = $app->login($username, $password);
if ($success) {
// $_SESSION['user_data'] is now populated
header("Location: dashboard/");
}$success = $app->register($username, $password, $licenseKey);
if (!$success) {
echo $app->lastError; // Display the error message
}$success = $app->license($licenseKey);$app->logout();
session_destroy();
header("Location: ../");function findSubscription($name, $subscriptions) {
foreach ($subscriptions as $sub) {
if ($sub->subscription === $name) return true;
}
return false;
}
$subs = $_SESSION['user_data']['subscriptions'];
if (findSubscription("premium", $subs)) {
echo "User has Premium access!";
}| Method | Description |
|---|---|
init() |
Initializes the session with the API. |
login($user, $pass, $code?) |
Authenticates a user. $code is for optional 2FA. |
register($user, $pass, $key, $email?) |
Registers a new user. |
license($key, $code?) |
Authenticates directly via license key. |
check() |
Validates the current session. |
logout() |
Terminates session and destroys user data. |
| Method | Description |
|---|---|
upgrade($user, $license) |
Upgrades user's subscription. |
forgot_password($user, $email) |
Triggers a password reset. |
change_username($new_username) |
Changes the current user's username. |
| Method | Description |
|---|---|
ban($reason) |
Bans the currently authenticated user. |
check_blacklist() |
Checks if the current machine is blacklisted. |
log($message) |
Sends a log message to the dashboard. |
| Method | Description |
|---|---|
get_global_var($var_key) |
Fetches a global server variable. |
get_var($var_name) |
Fetches a user-specific variable. |
set_var($var_name, $value) |
Sets a user-specific variable. |
download($fileid) |
Securely downloads a file (returns base64 decoded). |
| Method | Description |
|---|---|
fetch_online() |
Retrieves a list of online clients. |
chat_send($msg, $channel) |
Sends a chat message. |
chat_fetch($channel) |
Fetches chat history for a channel. |
Note: For any method that fails, check the
$app->lastErrorproperty for the error message.
Split-layout design with a dark branding panel and a glassmorphism form card with animated gradient orbs.
Dark-themed protected dashboard showing username, IP address (blur-to-reveal), account creation date, last login time, and active subscriptions with expiry dates.
| Concern | Recommendation |
|---|---|
.env file |
Add to .gitignore β never expose .env secrets |
| SSL Verification | Enable CURLOPT_SSL_VERIFYPEER in production |
| Session Handling | Use HTTPS in production to protect session cookies |
| Error Display | Disable display_errors in production (ini_set('display_errors', 0)) |
- Branding: Replace the
logo.webpfile with your own logo asset - Styling: The UI uses Tailwind CSS via CDN β swap for a local build for production
- Subscription Tiers: Edit the
findSubscription()call indashboard/index.phpto check for your specific subscription level names
| Library | Version | Purpose |
|---|---|---|
| Tailwind CSS | CDN | UI styling |
| Inter Font | Google Fonts | Typography |
| Bootstrap Icons | 1.11.1 | Icons |
| AuthVaultix API | 1.0 | Authentication |
Contributions, issues, and feature requests are welcome!
- Fork the repository
- Create a new branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m 'Add my feature' - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
- π AuthVaultix Documentation
- π¬ Discord Community
- π Open an Issue
This project is licensed under the MIT License β feel free to use, modify, and distribute it.
Made with β€οΈ using AuthVaultix