ray-skill
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRay Skill
Ray Skill
Overview
概述
Ray is Spatie's desktop debugging application for developers. Send data directly to Ray by making HTTP requests to its local server. This is what the PHP function does under the hood.
ray()Ray是Spatie为开发者打造的桌面调试应用。通过向其本地服务器发送HTTP请求,可直接将数据发送至Ray。这正是 PHP函数的底层实现逻辑。
ray()Connection Details
连接详情
| Setting | Default | Environment Variable |
|---|---|---|
| Host | | |
| Port | | |
| URL | | - |
| 设置项 | 默认值 | 环境变量 |
|---|---|---|
| Host | | |
| Port | | |
| URL | | - |
Request Format
请求格式
Method: POST
Content-Type:
User-Agent:
application/jsonRay 1.0请求方法: POST
Content-Type:
User-Agent:
application/jsonRay 1.0Basic Request Structure
基础请求结构
json
{
"uuid": "unique-identifier-for-this-ray-instance",
"payloads": [
{
"type": "log",
"content": { },
"origin": {
"file": "/path/to/file.php",
"line_number": 42,
"hostname": "my-machine"
}
}
],
"meta": {
"ray_package_version": "1.0.0"
}
}json
{
"uuid": "unique-identifier-for-this-ray-instance",
"payloads": [
{
"type": "log",
"content": { },
"origin": {
"file": "/path/to/file.php",
"line_number": 42,
"hostname": "my-machine"
}
}
],
"meta": {
"ray_package_version": "1.0.0"
}
}Fields
字段说明
| Field | Type | Description |
|---|---|---|
| string | Unique identifier for this Ray instance. Reuse the same UUID to update an existing entry. |
| array | Array of payload objects to send |
| object | Optional metadata (ray_package_version, project_name, php_version) |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | 当前Ray实例的唯一标识符。复用相同UUID可更新现有条目。 |
| 数组 | 待发送的Payload对象数组 |
| 对象 | 可选元数据(ray_package_version、project_name、php_version) |
Origin Object
Origin对象
Every payload includes origin information:
json
{
"file": "/Users/dev/project/app/Controller.php",
"line_number": 42,
"hostname": "dev-machine"
}每个Payload都包含来源信息:
json
{
"file": "/Users/dev/project/app/Controller.php",
"line_number": 42,
"hostname": "dev-machine"
}Payload Types
Payload类型
Log (Send Values)
日志(发送值)
json
{
"type": "log",
"content": {
"values": ["Hello World", 42, {"key": "value"}]
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}json
{
"type": "log",
"content": {
"values": ["Hello World", 42, {"key": "value"}]
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}Custom (HTML/Text Content)
自定义(HTML/文本内容)
json
{
"type": "custom",
"content": {
"content": "<h1>HTML Content</h1><p>With formatting</p>",
"label": "My Label"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}json
{
"type": "custom",
"content": {
"content": "<h1>HTML Content</h1><p>With formatting</p>",
"label": "My Label"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}Table
表格
json
{
"type": "table",
"content": {
"values": {"name": "John", "email": "john@example.com", "age": 30},
"label": "User Data"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}json
{
"type": "table",
"content": {
"values": {"name": "John", "email": "john@example.com", "age": 30},
"label": "User Data"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}Color
颜色设置
Set the color of the preceding log entry:
json
{
"type": "color",
"content": {
"color": "green"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}Available colors: , , , , ,
greenorangeredpurplebluegray设置前一条日志条目的颜色:
json
{
"type": "color",
"content": {
"color": "green"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}可用颜色: , , , , ,
greenorangeredpurplebluegrayScreen Color
屏幕背景色
Set the background color of the screen:
json
{
"type": "screen_color",
"content": {
"color": "green"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}设置Ray界面的背景色:
json
{
"type": "screen_color",
"content": {
"color": "green"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}Label
添加标签
Add a label to the entry:
json
{
"type": "label",
"content": {
"label": "Important"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}为条目添加标签:
json
{
"type": "label",
"content": {
"label": "Important"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}Size
调整尺寸
Set the size of the entry:
json
{
"type": "size",
"content": {
"size": "lg"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}Available sizes: ,
smlg设置条目的显示尺寸:
json
{
"type": "size",
"content": {
"size": "lg"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}可用尺寸: ,
smlgNotify (Desktop Notification)
桌面通知
json
{
"type": "notify",
"content": {
"value": "Task completed!"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}json
{
"type": "notify",
"content": {
"value": "Task completed!"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}New Screen
新建屏幕
json
{
"type": "new_screen",
"content": {
"name": "Debug Session"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}json
{
"type": "new_screen",
"content": {
"name": "Debug Session"
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}Measure (Timing)
性能计时
json
{
"type": "measure",
"content": {
"name": "my-timer",
"is_new_timer": true,
"total_time": 0,
"time_since_last_call": 0,
"max_memory_usage_during_total_time": 0,
"max_memory_usage_since_last_call": 0
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}For subsequent measurements, set and provide actual timing values.
is_new_timer: falsejson
{
"type": "measure",
"content": {
"name": "my-timer",
"is_new_timer": true,
"total_time": 0,
"time_since_last_call": 0,
"max_memory_usage_during_total_time": 0,
"max_memory_usage_since_last_call": 0
},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}后续计时时,需设置并传入实际的计时数值。
is_new_timer: falseSimple Payloads (No Content)
无内容的简单Payload
These payloads only need a and empty :
typecontentjson
{
"type": "separator",
"content": {},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}| Type | Purpose |
|---|---|
| Add visual divider |
| Clear all entries |
| Hide this entry |
| Remove this entry |
| Show confetti animation |
| Bring Ray to foreground |
| Hide Ray window |
这类Payload仅需指定和空:
typecontentjson
{
"type": "separator",
"content": {},
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}| 类型 | 用途 |
|---|---|
| 添加视觉分隔线 |
| 清空所有条目 |
| 隐藏当前条目 |
| 删除当前条目 |
| 展示彩屑动画 |
| 将Ray窗口前置显示 |
| 隐藏Ray窗口 |
Combining Multiple Payloads
组合多个Payload
Send multiple payloads in one request. Use the same to apply modifiers (color, label, size) to a log entry:
uuidjson
{
"uuid": "abc-123",
"payloads": [
{
"type": "log",
"content": { "values": ["Important message"] },
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
},
{
"type": "color",
"content": { "color": "red" },
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
},
{
"type": "label",
"content": { "label": "ERROR" },
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
},
{
"type": "size",
"content": { "size": "lg" },
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}
],
"meta": {}
}可在单个请求中发送多个Payload。使用相同可为某条日志条目应用多个修饰符(颜色、标签、尺寸):
uuidjson
{
"uuid": "abc-123",
"payloads": [
{
"type": "log",
"content": { "values": ["Important message"] },
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
},
{
"type": "color",
"content": { "color": "red" },
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
},
{
"type": "label",
"content": { "label": "ERROR" },
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
},
{
"type": "size",
"content": { "size": "lg" },
"origin": { "file": "test.php", "line_number": 1, "hostname": "localhost" }
}
],
"meta": {}
}Example: Complete Request
示例:完整请求
Send a green, labeled log message:
bash
curl -X POST http://localhost:23517/ \
-H "Content-Type: application/json" \
-H "User-Agent: Ray 1.0" \
-d '{
"uuid": "my-unique-id-123",
"payloads": [
{
"type": "log",
"content": {
"values": ["User logged in", {"user_id": 42, "name": "John"}]
},
"origin": {
"file": "/app/AuthController.php",
"line_number": 55,
"hostname": "dev-server"
}
},
{
"type": "color",
"content": { "color": "green" },
"origin": { "file": "/app/AuthController.php", "line_number": 55, "hostname": "dev-server" }
},
{
"type": "label",
"content": { "label": "Auth" },
"origin": { "file": "/app/AuthController.php", "line_number": 55, "hostname": "dev-server" }
}
],
"meta": {
"project_name": "my-app"
}
}'发送一条绿色、带标签的日志消息:
bash
curl -X POST http://localhost:23517/ \
-H "Content-Type: application/json" \
-H "User-Agent: Ray 1.0" \
-d '{
"uuid": "my-unique-id-123",
"payloads": [
{
"type": "log",
"content": {
"values": ["User logged in", {"user_id": 42, "name": "John"}]
},
"origin": {
"file": "/app/AuthController.php",
"line_number": 55,
"hostname": "dev-server"
}
},
{
"type": "color",
"content": { "color": "green" },
"origin": { "file": "/app/AuthController.php", "line_number": 55, "hostname": "dev-server" }
},
{
"type": "label",
"content": { "label": "Auth" },
"origin": { "file": "/app/AuthController.php", "line_number": 55, "hostname": "dev-server" }
}
],
"meta": {
"project_name": "my-app"
}
}'Availability Check
可用性检测
Before sending data, you can check if Ray is running:
GET http://localhost:23517/_availability_checkRay responds with HTTP 404 when available (the endpoint doesn't exist, but the server is running).
发送数据前,可先检测Ray是否运行:
GET http://localhost:23517/_availability_check当Ray可用时,会返回HTTP 404状态码(该端点不存在,但服务器处于运行状态)。
Payload Type Reference
Payload类型参考
| Type | Content Fields | Purpose |
|---|---|---|
| | Send values to Ray |
| | HTML or text content |
| | Display as table |
| | Set entry color |
| | Set screen background |
| | Add label to entry |
| | Set entry size (sm/lg) |
| | Desktop notification |
| | Create new screen |
| | Performance timing |
| (empty) | Visual divider |
| (empty) | Clear all entries |
| (empty) | Hide entry |
| (empty) | Remove entry |
| (empty) | Confetti animation |
| (empty) | Show Ray window |
| (empty) | Hide Ray window |
| 类型 | 内容字段 | 用途 |
|---|---|---|
| | 向Ray发送数据值 |
| | 发送HTML或文本内容 |
| | 以表格形式展示数据 |
| | 设置条目颜色 |
| | 设置界面背景色 |
| | 为条目添加标签 |
| | 设置条目显示尺寸(sm/lg) |
| | 发送桌面通知 |
| | 创建新的调试屏幕 |
| | 性能计时统计 |
| (空) | 添加视觉分隔线 |
| (空) | 清空所有条目 |
| (空) | 隐藏当前条目 |
| (空) | 删除当前条目 |
| (空) | 展示彩屑动画 |
| (空) | 前置显示Ray窗口 |
| (空) | 隐藏Ray窗口 |