Laravel启动器

a2a-laravel-starter — Laravel 启动器模板

作者 praveendias1180

基于 Laravel 的 A2A 代理起始项目,内置单位换算示例代理,克隆后即可运行并替换为自己的代理逻辑。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

3 个预览视图
桌面端首页1 / 3
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 3

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-14查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

克隆后即可运行,代理默认监听 http://localhost:8000

02

提供 Agent Card、JSON-RPC 与 HTTP+JSON 三类 A2A 入口

03

内置单位换算示例代理,支持长度、质量、体积和温度

04

演示多轮任务:缺少目标单位时追问,回答后在同一任务中完成

05

仅四个文件与 A2A 相关,其余为普通 Laravel 应用

06

提供 php artisan a2a:make-executor 和 php artisan a2a:card 命令辅助开发

模板详细介绍

这是一个 Laravel 应用模板,本身已经是一个 A2A(Agent2Agent)代理。它构建在 praveendias1180/a2a-laravel 之上,后者是 A2A PHP SDK 的 Laravel 桥接层;README 说明该 SDK 面向 A2A 1.0,与官方 Python SDK 结构相似,并通过官方 A2A TCK。

按 README 的说明,可以通过 composer create-project praveendias1180/a2a-laravel-starter my-agent 创建项目,或使用 GitHub 的 Use this template 后运行 composer run setup,再执行 php artisan serve 启动,代理会运行在 http://localhost:8000。启动后提供三个入口:/.well-known/agent-card.json 返回 Agent Card,/a2a/jsonrpc 是 JSON-RPC 端点,/a2a/rest/... 是 HTTP+JSON 端点。

示例代理是一个单位换算器,支持长度、质量、体积和温度。如果请求中缺少目标单位(例如 convert 10 km),它会追问 To which unit?,在同一任务中回答 miles 后继续完成,从而演示多轮 A2A 任务(先 INPUT_REQUIRED,后 COMPLETED)。README 指出只有四个文件与 A2A 相关:routes/a2a.php 用一行 Route::a2a(...) 挂载卡片和两个端点;app/A2A/UnitConverterAgentCard.php 定义卡片;app/A2A/UnitConverterExecutor.php 把消息转换为任务事件;app/A2A/UnitConverter.php 是纯 PHP 的换算逻辑,不含 A2A 代码。其余部分是普通 Laravel 应用。

README 未提供该模板的性能、并发能力或生产环境就绪程度的说明;生产相关建议仅包括为路由添加认证中间件、通过 A2A_RUNNER=queued 使用队列执行、为 nginx 关闭响应缓冲以支持流式传输,以及用 php artisan a2a:prune 清理旧任务。

Laravel启动器

适合你的项目吗?

适用场景

  • 用官方 A2A CLI 或 curl 向本地代理发送消息并观察流式响应
  • 以单位换算代理为起点,替换为调用 LLM、数据库或外部 API 的代理
  • 参考 tests/Feature/UnitConverterAgentTest.php 编写自己的代理测试
  • 按 README 的生产建议为路由添加认证、启用队列执行或配置 nginx 流式传输

适合人群

  • 希望快速获得一个可运行的 A2A 代理的 Laravel 开发者
  • 需要参考 A2A 任务事件与多轮交互实现方式的开发者
  • 计划在 Laravel 应用中接入 A2A PHP SDK 的团队

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    使用 composer create-project praveendias1180/a2a-laravel-starter my-agent 创建项目,或使用 GitHub 模板后运行 composer run setup

  2. 2

    执行 php artisan serve 启动,代理运行在 http://localhost:8000

  3. 3

    可用 a2a send -a http://localhost:8000 --stream "convert 10 km to miles" 或 curl 调用 /a2a/rest/message:send 进行测试

  4. 4

    运行 php artisan test 执行测试;php artisan a2a:card 可打印并校验 Agent Card

  5. 5

    生产环境相关配置(认证中间件、A2A_RUNNER=queued、nginx 关闭缓冲、a2a:prune 调度)需按 README 指引自行设置

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 Apache-2.0 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发;分发时需随附 Apache-2.0 许可证。
  • 修改过的文件需显著标明改动,并保留相关版权、专利、商标及归属声明。
  • 若原项目附有 NOTICE 文件,分发衍生作品时需保留其中适用的归属声明。
  • 许可包含适用的贡献者专利授权;发起许可所述专利诉讼会终止该专利授权,且不授予商标使用权。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 Apache-2.0 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-14。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 80 / 100
技术栈
Laravel
网站类型
启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-10-14
截图检查日期
2026-10-14

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Laravel。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: codex-user-requested-batch-review-20261015 · 2026-10-15

查看当时使用的来源资料

SHA-256: 3b24de5b894d746bec069230bbdd9b1e7ec049d6f9ad9b98229ebb8cd602f1a8

2026-10-14T16:06:47.570Z

来源文件 / 仓库
# A2A Laravel Starter

A Laravel app that is already an [A2A (Agent2Agent)](https://a2a-protocol.org/latest/specification/) agent. Clone it, run it, then swap the example agent for your own.

![The starter's agent answering the A2A CLI: its Agent Card, a streamed conversion, and a multi-turn task that asks for the missing unit](art/demo.gif)

It is built on [`praveendias1180/a2a-laravel`](https://github.com/praveendias1180/a2a-php), the Laravel bridge for the A2A PHP SDK. That SDK targets **A2A 1.0**, has the same shape as the official Python SDK, and passes the official A2A TCK.

## Run it in 2 minutes

```bash
composer create-project praveendias1180/a2a-laravel-starter my-agent
cd my-agent
php artisan serve
```

Or click **Use this template** on GitHub, clone your copy, and run `composer run setup`, then `php artisan serve`.

Your agent is now live at `http://localhost:8000`:

| URL | What |
|---|---|
| `/.well-known/agent-card.json` | the Agent Card, which tells other agents what yours can do |
| `/a2a/jsonrpc` | the JSON-RPC endpoint |
| `/a2a/rest/...` | the HTTP+JSON endpoint |

## Talk to it

With the official [A2A CLI](https://github.com/a2aproject/a2a-cli):

```bash
a2a send -a http://localhost:8000 --stream "convert 10 km to miles"
```

Or with curl:

```bash
curl -s http://localhost:8000/a2a/rest/message:send \
  -H 'Content-Type: application/json' -H 'A2A-Version: 1.0' \
  -d '{"message":{"messageId":"1","role":"ROLE_USER","parts":[{"text":"72 f in c"}]}}'
```

The example agent is a unit converter. It knows length, mass, volume and temperature. Leave out the target unit (`convert 10 km`) and it asks `To which unit?`. Answer `miles` on the same task, and it finishes the job. That shows a multi-turn A2A task (`INPUT_REQUIRED`, then `COMPLETED`).

## What's inside

Only four files are about A2A:

| File | What it does |
|---|---|
| [`routes/a2a.php`](routes/a2a.php) | One `Route::a2a(...)` line mounts the card and both endpoints |
| [`app/A2A/UnitConverterAgentCard.php`](app/A2A/UnitConverterAgentCard.php) | The Agent Card: name, skills, capabilities |
| [`app/A2A/UnitConverterExecutor.php`](app/A2A/UnitConverterExecutor.php) | Turns a message into task events (working, artifact, completed) |
| [`app/A2A/UnitConverter.php`](app/A2A/UnitConverter.php) | The agent's actual logic: plain PHP, with no A2A in it |

Everything else is a normal Laravel 13 app.

## Make it your own

1. **Replace the logic.** Edit `app/A2A/UnitConverter.php`, or write a new class that calls an LLM, your database or an API. The executor only needs a string back.
2. **Update the card.** Change the name, description and skills in `UnitConverterAgentCard.php`. Other agents read these to decide whether to call you.
3. **Or start a fresh agent.** `php artisan a2a:make-executor Support` writes `app/A2A/SupportExecutor.php`. Then point the route at it.
4. **Check the card.** `php artisan a2a:card` prints it as served and validates it.

## Tests

```bash
php artisan test
```

[`tests/Feature/UnitConverterAgentTest.php`](tests/Feature/UnitConverterAgentTest.php) calls the agent the way another agent would: over JSON-RPC and HTTP+JSON, with streaming and with a multi-turn task. Copy its helpers when you test your own agent.

## Going to production

- **Protect it.** Add `->middleware('auth:sanctum')` (or any auth) to the route in `routes/a2a.php`. The Agent Card stays public, which discovery needs. Tasks are scoped to the signed-in user.
- **Long-running work.** Set `A2A_RUNNER=queued` so executors run on your queue workers instead of in the web request. See [queued execution](https://praveendias1180.github.io/a2a-php/guides/laravel-queues/).
- **Streaming behind nginx.** Turn off response buffering for the A2A routes. See [SSE with nginx and PHP-FPM](https://praveendias1180.github.io/a2a-php/guides/laravel-sse-nginx/).
- **Clean up old tasks.** Schedule `php artisan a2a:prune`.

## Learn more

- [Laravel guide](https://praveendias1180.github.io/a2a-php/guides/laravel/)
- [A2A in five minutes](https://praveendias1180.github.io/a2a-php/concepts/a2a-in-five-minutes/)
- [A2A PHP SDK on GitHub](https://github.com/praveendias1180/a2a-php)
- [The A2A specification](https://a2a-protocol.org/latest/specification/)

## License

Apache-2.0. The Laravel skeleton this starts from is MIT-licensed.
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。