承接 alirezax5/threex-ui-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alirezax5/threex-ui-php

Composer 安装命令:

composer require 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.

README 文档

README

Language: English | فارسی

PHP Version License Tests

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

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

Dependency Version
PHP >= 8.1
ext-curl * (required)
ext-json * (required)
ext-mbstring * (required)

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

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

use ThreeXUI\ThreeXUI;

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

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

Usage Overview

API Group Access Method Description
Inbounds $panel->inbounds() CRUD inbound connections
Clients $panel->clients() User/client management + bulk ops
Client Groups $panel->clientGroups() Group clients together
Server $panel->server() System status, Xray control, logs
Nodes $panel->nodes() Multi-node cluster management
Settings $panel->settings() Panel settings + API token mgmt
Xray Config $panel->xrayConfig() Xray core configuration
Custom Geo $panel->customGeo() Custom geoip/geosite sources
Subscriptions $panel->subscriptions() Subscription links + Telegram backup

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

// 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

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

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

MIT License. See LICENSE for details.

Related

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固