PHPackages                             yangweijie/ui - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yangweijie/ui

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yangweijie/ui
=============

ui extension wrapper for kingbes/libui

v0.5.0(6mo ago)00MITPHP

Since Oct 17Pushed 6mo agoCompare

[ Source](https://github.com/yangweijie/kingbes-libui-sdk)[ Packagist](https://packagist.org/packages/yangweijie/ui)[ RSS](/packages/yangweijie-ui/feed)WikiDiscussions main2 Synced 1mo ago

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

UI
==

[](#ui)

这是一个对 [kingbes/libui](https://github.com/kingbes/php-libui) 的面向对象封装，提供了更符合 PHP 习惯的 API，灵感来源于 [PHP 官方的 UI 扩展](https://www.php.net/manual/zh/book.ui.php)。

安装
--

[](#安装)

```
composer require yangweijie/ui
```

使用示例
----

[](#使用示例)

### 简单按钮示例

[](#简单按钮示例)

```
// example/button.php

require dirname(__DIR__) . "/vendor/autoload.php";

use UI\UI;
use UI\Window;
use UI\Size;
use UI\Controls\Box;
use UI\Controls\Orientation;
use UI\Controls\Button;

// 初始化应用
UI::init();

// 创建窗口
$window = new Window("窗口", new Size(640, 480), false);
// 窗口设置边框
$window->setMargin(true);

// 窗口关闭事件
$window->onClose(function ($window) {
    echo "窗口关闭\n";
    // 退出应用
    UI::exit();
    // 返回 true：关闭窗口, false：不关闭
    return true;
});

// 创建垂直容器
$box = new Box(Orientation::Vertical);
$box->setPadded(true); // 设置边距
$window->setChild($box); // 设置窗口子元素

// 创建按钮
$btn01 = new Button("按钮");
// 按钮点击事件
$btn01->onClick(function ($btn01) use ($window) {
    echo "按钮点击\n";
    $window->msgBox("提示", "世界上最好的语言PHP~");
});
// 追加按钮到容器
$box->append($btn01, false);

// 显示窗口
$window->show();

// 启动主循环
UI::run();
```

运行示例：

```
php example/button.php
```

测试
--

[](#测试)

本项目使用 Pest 作为测试框架。要运行测试，请执行以下命令：

```
# 运行所有测试
php run_pest_tests.php

# 或者直接使用 Pest
php vendor/pestphp/pest/bin/pest
```

API 设计
------

[](#api-设计)

本库的 API 设计尽可能贴近 PHP 官方 UI 扩展的接口，方便开发者学习和使用。

核心类包括：

- `UI\UI`: UI 入口。
- `UI\Window`: 窗口控件。
- `UI\Size`: 用于表示尺寸。
- `UI\Control`: 所有控件的基类。
- `UI\Controls\Box`: 布局容器。
- `UI\Controls\Button`: 按钮控件。
- 更多控件正在封装中...

依赖
--

[](#依赖)

- PHP 8.2+
- [kingbes/libui](https://github.com/kingbes/php-libui)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance68

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~13 days

Total

2

Last Release

196d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0b5f090a9bb92727e9c2e8281d05c2da5f2f9bf66cf1811714a9ffc0e383325?d=identicon)[yangweijie](/maintainers/yangweijie)

---

Top Contributors

[![yangweijie](https://avatars.githubusercontent.com/u/1614114?v=4)](https://github.com/yangweijie "yangweijie (10 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/yangweijie-ui/health.svg)

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

PHPackages © 2026

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