PHPackages                             alirezax5/threex-ui-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. alirezax5/threex-ui-php

ActiveLibrary[API Development](/categories/api)

alirezax5/threex-ui-php
=======================

A modern, modular PHP client for the 3X-UI Panel API - manage Xray/V2Ray inbounds, clients, nodes, and server settings programmatically.

1.1.0(1mo ago)03MITPHP &gt;=8.1

Since Jul 6Compare

[ Source](https://github.com/alirezax5/threex-ui-php)[ Packagist](https://packagist.org/packages/alirezax5/threex-ui-php)[ RSS](/packages/alirezax5-threex-ui-php/feed)WikiDiscussions Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

3X-UI PHP Client
================

[](#3x-ui-php-client)

> **Language:** [English](#) | [فارسی](README.fa.md)

[![PHP Version](https://camo.githubusercontent.com/6518db1335bf20fdff07253dc6d6d0cec955b5fb6a8ef1382ac6d73687ecc07f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c7565)](composer.json)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)[![Tests](https://camo.githubusercontent.com/230c6802a4e7b6cfdb02dd037363b7a35ef3cb49d95787f043ec7ee0382b027f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d3134342532307061737365642d627269676874677265656e)](tests/)

A modern, modular, and optimized **PHP 8.1+ client** for the [3X-UI Panel](https://github.com/MHSanaei/3x-ui) REST API — programmatically manage Xray/V2Ray inbounds, clients, nodes, server settings, and subscriptions.

Features
--------

[](#features)

- **Full API Coverage** — ~96 endpoints across 9 functional groups
- **Dual Authentication** — API token (Bearer) or session-based login
- **Modular Architecture** — Each API group is a separate, testable class
- **Type-Safe** — PHP 8.1+ with strict types, readonly properties, and full type-hinting
- **PSR-4** — Composer autoloading with clean namespace structure
- **Zero Dependencies** — Uses native `ext-curl` and `ext-json` only
- **Helper Functions** — Global convenience functions for common tasks
- **Comprehensive Error Handling** — Custom exceptions for auth, API, connection, and validation errors
- **Validator** — Built-in input validation for emails, UUIDs, ports, protocols
- **Formatter** — Bytes/Gigabytes conversion, timestamps, and sanitization

Requirements
------------

[](#requirements)

DependencyVersionPHP&gt;= 8.1ext-curl\* (required)ext-json\* (required)ext-mbstring\* (required)Installation
------------

[](#installation)

```
composer require alirezax5/threex-ui-php
```

Or clone directly:

```
git clone https://github.com/alirezax5/threex-ui-php.git
cd threex-ui-php
composer install
```

Quick Start
-----------

[](#quick-start)

### Authentication via API Token (Recommended)

[](#authentication-via-api-token-recommended)

```
use ThreeXUI\ThreeXUI;

$panel = new ThreeXUI('https://your-panel.example.com:54321');
$panel->withApiToken('your-api-token-from-settings');

$inbounds = $panel->inbounds()->list();
```

### Authentication via Session Login

[](#authentication-via-session-login)

```
use ThreeXUI\ThreeXUI;

$panel = new ThreeXUI('https://your-panel.example.com:54321');
$panel->login('admin', 'your-password');

$status = $panel->server()->status();
```

Usage Overview
--------------

[](#usage-overview)

API GroupAccess MethodDescriptionInbounds`$panel->inbounds()`CRUD inbound connectionsClients`$panel->clients()`User/client management + bulk opsClient Groups`$panel->clientGroups()`Group clients togetherServer`$panel->server()`System status, Xray control, logsNodes`$panel->nodes()`Multi-node cluster managementSettings`$panel->settings()`Panel settings + API token mgmtXray Config`$panel->xrayConfig()`Xray core configurationCustom Geo`$panel->customGeo()`Custom geoip/geosite sourcesSubscriptions`$panel->subscriptions()`Subscription links + Telegram backupExamples
--------

[](#examples)

```
// Add a VLESS inbound
$panel->inbounds()->add([
    'remark'   => 'VLESS + Reality',
    'port'     => 443,
    'protocol' => 'vless',
    'settings' => json_encode(['clients' => [], 'decryption' => 'none', 'fallbacks' => []]),
    'streamSettings' => json_encode(['network' => 'tcp', 'security' => 'reality']),
    'sniffing' => json_encode(['enabled' => true, 'destOverride' => ['http', 'tls']]),
]);

// Add a client
$panel->clients()->add(
    ['email' => 'user@example.com', 'totalGB' => 100],
    [1] // attach to inbound ID 1
);

// Get server status
$status = $panel->server()->status();
// CPU, RAM, Disk, Xray running state...

// Generate Reality keypair
$keys = $panel->server()->getNewX25519Cert();

// Reset all client traffic
$panel->clients()->resetAllTraffics();
```

Helper Functions
----------------

[](#helper-functions)

```
// Global convenience helpers
$client = threexui_client('https://panel:54321', 'token');

bytes_to_human(1073741824);          // "1 GB"
human_to_bytes('500 MB');            // 524288000
gb_to_bytes(10.5);                   // 11274289152
bytes_to_gb(10737418240);            // 10.0
validate_uuid('550e8400-e29b-...');  // true
validate_protocol('vless');          // true
validate_port(8080);                 // true
array_dot_get($data, 'settings.clients.0.email');
```

Project Structure
-----------------

[](#project-structure)

```
threex-ui-php/
├── src/
│   ├── ThreeXUI.php              # Main facade
│   ├── Config.php                # Configuration
│   ├── HttpClient.php            # cURL HTTP client
│   ├── Authentication.php        # Login/logout/2FA
│   ├── Contracts/
│   │   ├── HttpClientInterface.php
│   │   └── EndpointInterface.php
│   ├── Endpoints/
│   │   ├── Inbounds.php
│   │   ├── Clients.php
│   │   ├── ClientGroups.php
│   │   ├── Server.php
│   │   ├── Nodes.php
│   │   ├── Settings.php
│   │   ├── XrayConfig.php
│   │   ├── CustomGeo.php
│   │   └── Subscriptions.php
│   ├── Exceptions/
│   │   ├── ThreeXUIException.php
│   │   ├── AuthenticationException.php
│   │   ├── ApiException.php
│   │   ├── ConnectionException.php
│   │   └── ValidationException.php
│   └── Helpers/
│       ├── Validator.php
│       ├── Formatter.php
│       ├── ArrayHelper.php
│       └── functions.php
├── examples/
│   ├── basic-usage.php
│   ├── inbounds.php
│   └── clients.php
├── composer.json
├── README.md
├── DOCUMENTATION.md
├── llm.txt
└── llm-full.txt

```

Error Handling
--------------

[](#error-handling)

```
use ThreeXUI\Exceptions\AuthenticationException;
use ThreeXUI\Exceptions\ApiException;
use ThreeXUI\Exceptions\ConnectionException;
use ThreeXUI\Exceptions\ValidationException;

try {
    $panel->login('admin', 'wrong-password');
} catch (AuthenticationException $e) {
    echo "Auth failed: " . $e->getMessage();
} catch (ConnectionException $e) {
    echo "Network error: " . $e->getMessage();
} catch (ApiException $e) {
    echo "API error: " . $e->getMessage();
    $responseData = $e->getResponseData();
} catch (ValidationException $e) {
    echo "Validation error: " . $e->getMessage();
}
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Related
-------

[](#related)

- [3X-UI Panel](https://github.com/MHSanaei/3x-ui) — The Xray panel this client connects to
- [API Documentation](https://documenter.getpostman.com/view/5146551/2sBXwnsBko) — Official Postman docs

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

48d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20362833?v=4)[alireza x5](/maintainers/alirezax5)[@alirezax5](https://github.com/alirezax5)

---

Tags

apiclientpanelxray3x-uiShadowsocksv2raytrojanvlessvmess

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alirezax5-threex-ui-php/health.svg)

```
[![Health](https://phpackages.com/badges/alirezax5-threex-ui-php/health.svg)](https://phpackages.com/packages/alirezax5-threex-ui-php)
```

###  Alternatives

[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47394.5k5](/packages/deepseek-php-deepseek-php-client)[walle89/swedbank-json

Unofficial API client for the Swedbank's and Sparbanken's mobile apps in Sweden.

772.5k](/packages/walle89-swedbank-json)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1244.0k1](/packages/skeeks-yii2-google-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
