PHPackages                             xuchunyang/ray-think - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. xuchunyang/ray-think

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

xuchunyang/ray-think
====================

Ray debugging client for ThinkPHP 8

03PHP

Since May 11Pushed 4w agoCompare

[ Source](https://github.com/xuchunyang/ray-think)[ Packagist](https://packagist.org/packages/xuchunyang/ray-think)[ RSS](/packages/xuchunyang-ray-think/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Ray Think
=========

[](#ray-think)

[![Packagist Version](https://camo.githubusercontent.com/cc4ecdff3e61531e1f707f5699bc22d0811b28defefe51b899cb91724da73830/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f78756368756e79616e672f7261792d7468696e6b)](https://packagist.org/packages/xuchunyang/ray-think)[![Packagist Downloads](https://camo.githubusercontent.com/9c59db34357044fa661eedaf6f91c0b9047b6dfdbf00ea6b7f6ab3f3887fd9c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f78756368756e79616e672f7261792d7468696e6b)](https://packagist.org/packages/xuchunyang/ray-think)[![License](https://camo.githubusercontent.com/c2b57ec362b1ab78be5d507878f9facece249e7e72f04c9ba2f90f3bed2053d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f78756368756e79616e672f7261792d7468696e6b)](https://packagist.org/packages/xuchunyang/ray-think)

ThinkPHP 8 的 Ray 调试客户端。配合 [Ray Server](https://github.com/xuchunyang/ray-server) 使用。

安装
--

[](#安装)

```
composer require xuchunyang/ray-think
```

服务会自动注册（通过 `extra.think.services` 自动发现）。

配置
--

[](#配置)

发布配置文件（可选）：

```
php think vendor:publish xuchunyang/ray-think
```

或手动创建 `config/ray.php`：

```
return [
    'enabled' => env('ray.enabled', app()->isDebug()),
    'server_url' => env('ray.server_url', 'http://127.0.0.1:23517'),
    'timeout' => 0.5,
    'sensitive_keys' => ['password', 'token', 'secret'],
    'middleware_enabled' => true,
];
```

环境变量：

```
RAY_ENABLED=true
RAY_SERVER_URL=http://127.0.0.1:23517
RAY_TIMEOUT=0.5
```

使用
--

[](#使用)

### 基础输出

[](#基础输出)

```
// 普通日志
ray('hello world');
ray($user, $data, $config);

// JSON
ray()->json(['id' => 1, 'name' => 'Tom'], 'User Info');

// 表格
ray()->table([
    ['name' => 'Alice', 'score' => 95],
    ['name' => 'Bob', 'score' => 82],
], 'Exam Results');

// SQL
ray()->sql('SELECT * FROM users WHERE id = ?', [1], 12.5, 'mysql');

// 异常
try { ... } catch (\Throwable $e) {
    ray()->exception($e);
}

// 图片
ray()->image('https://example.com/chart.png');
ray()->image('/tmp/debug.png');  // 本地文件自动转 base64
```

### 链式调用

[](#链式调用)

```
// 颜色
ray('success')->green();
ray('warning')->orange();
ray('error')->red();
ray('info')->blue();
ray('special')->purple();
ray('muted')->gray();
ray('alert')->yellow();

// 标签
ray('deployed!')->label('Deploy');

// 大小
ray('debug info')->small();
ray('important!')->large();

// 组合
ray('Server is down!')->red()->label('Critical')->small();
ray(['status' => 'ok'])->green()->label('Health Check');
ray()->table($data)->orange()->label('Slow Queries');
```

### Screen 分组

[](#screen-分组)

```
ray()->screen('用户模块');
ray('这条消息在用户模块下');

ray()->screen('订单模块');
ray('这条消息在订单模块下');
```

### 辅助函数

[](#辅助函数)

```
ray('hello');           // 输出
ray()->json($data);     // 链式
ray_screen('模块名');    // 切换分组
ray_clear();            // 清空
```

自动功能
----

[](#自动功能)

- **请求/响应记录**：中间件自动记录每个 HTTP 请求和响应
- **SQL 监听**：自动捕获数据库查询
- **敏感字段脱敏**：password、token、api\_key 等自动替换为 `***`
- **生产环境禁用**：`APP_DEBUG=false` 时完全跳过，零开销
- **快速失败**：Server 不可达时，5秒内跳过后续请求，不卡业务

生产环境
----

[](#生产环境)

`APP_DEBUG=false` 时，Ray 完全禁用：

- `ray()` 调用直接返回空对象
- 不走容器、不创建对象、不发 HTTP
- 4万次调用耗时约 8ms，每次 0.0002ms

配合服务端使用
-------

[](#配合服务端使用)

启动 [Ray Server](https://github.com/xuchunyang/ray-server)：

```
cd ray-server
./ray-server
```

然后在 ThinkPHP 项目中使用 `ray()` 即可。

License
-------

[](#license)

MIT

###  Health Score

21

↑

LowBetter than 18% of packages

Maintenance61

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e733e29ff088f888ddc8423dd7054752c386dd02a241e2bb9b7e571143a053e?d=identicon)[xuchunyang](/maintainers/xuchunyang)

---

Top Contributors

[![xuchunyang](https://avatars.githubusercontent.com/u/4550353?v=4)](https://github.com/xuchunyang "xuchunyang (3 commits)")

### Embed Badge

![Health badge](/badges/xuchunyang-ray-think/health.svg)

```
[![Health](https://phpackages.com/badges/xuchunyang-ray-think/health.svg)](https://phpackages.com/packages/xuchunyang-ray-think)
```

###  Alternatives

[beyondcode/helo-laravel

HELO Laravel debug helper

90363.7k](/packages/beyondcode-helo-laravel)[phalcon/dd

This package will add the `dd` and `dump` helpers to your Phalcon application.

24296.9k27](/packages/phalcon-dd)

PHPackages © 2026

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