2026 年 5 月带来了 Laravel Cloud 全栈 Scale-to-Zero 与 Managed Queues、字体优化、多智能体流水线等一系列实用的大型更新。
参考出处:Laravel May Product Updates
Laravel Framework
@fonts Blade 指令
新增 @fonts 指令,自动处理加载 Web 字体所需的 <link rel="preload"> 标签、@font-face 样式、HTTP/2 推送头。它会读取 Vite 字体插件生成的字体清单,把必要的元素一次性注入。
{{-- 加载所有字体 --}}
@fonts
{{-- 只加载指定字体族 --}}
@fonts(["sans", "mono"])
@fonts 让每个页面只控制自己需要的字体,避免不必要的预加载,优化性能。
Interruptible Jobs(支持信号的作业)
通过新的 Interruptible 接口,队列 Worker 在部署过程中接收到 SIGTERM 时,作业可以对此作出响应。可以在 Worker 关停前安全地停止循环、释放锁、保存状态等。
use Illuminate\Contracts\Queue\Interruptible;
use Illuminate\Contracts\Queue\ShouldQueue;
class ProcessLargeReport implements ShouldQueue, Interruptible
{
public function handle(): void
{
foreach ($this->getChunks() as $chunk) {
if ($this->shouldInterrupt()) {
$this->saveProgress();
return;
}
$this->processChunk($chunk);
}
}
}
API 路由默认返回 JSON 异常
API 路由现在会自动以 JSON 格式返回错误响应。之前 API 路由在某些情况下也可能返回 HTML,现在在 api.php 中定义的路由始终会返回 JSON 响应。
存储缓存 store
新增 storage 缓存 store。它以文件系统作为缓存后端,同时可以利用 Laravel 的存储配置。
// config/cache.php
'stores' => [
'storage' => [
'driver' => 'storage',
'disk' => 'local',
'path' => 'framework/cache',
],
],
大容量 SQS 负载存盘
新增了当 SQS 负载过大(超过 256KB)时保存到磁盘的选项。在队列中处理大数据时很有用。
调度命令按环境过滤
schedule:list 命令现在支持按环境过滤。
php artisan schedule:list --environment=production
Worker 的 Stop When Empty 选项
新增 --stop-when-empty 选项,队列为空时自动停止 Worker。对批处理或 CI 环境中需要在队列排空后终止的 Worker 非常方便。
php artisan queue:work --stop-when-empty
foreignUuidFor 模式 helper
作为 foreignIdFor() 的 UUID 版本,新增了 foreignUuidFor()。
Schema::table('posts', function (Blueprint $table) {
$table->foreignUuidFor(User::class)->constrained();
});
AI 子智能体支持
Laravel AI 智能体现在可以委派给其他智能体。只要从 tools() 方法返回任意智能体,父智能体的 LLM 就会像调用普通工具一样调用它。上下文互相隔离,对话历史不会混杂。
class OrchestratorAgent extends Agent
{
public function tools(): array
{
return [
new AnalysisAgent(),
new WritingAgent(),
new SearchTool(),
];
}
}
Inertia 3.x
router.poll 的 mode 选项:可配置轮询的行为模式
usePoll 支持动态数据:在轮询过程中动态更新数据
Inertia.once:支持只触发一次的事件
<Deferred> 的 rescue 插槽:defer 属性失败时的回退
PAO(PHP Agentic Output)
启动套件已默认集成 PAO。此外还新增了以下功能:
- Rector 支持:PAO 也处理 Rector 的 JSON 输出
- PHPStan 的智能体指引:新增向智能体说明错误位置修复方式的指引
PAO_FORCE 环境变量:强制启用 PAO 模式
- Artisan RECTOR 支持:PAO 支持 Artisan 命令
Laravel Cloud / Laravel Forge / Nightwatch
| 产品 | 主要更新 |
|---|
| Laravel Cloud | 全栈 Scale-to-Zero(500ms 内启动,提速 20 倍)、Managed Queues(自动扩缩 Worker、失败作业面板)、支出上限、套餐更新(月付 $5 Starter 套餐) |
| Laravel Forge | Managed MySQL 8.4(自动备份、只读副本、告警),PHP 8.5 成为默认版本,env 变化时自动重启 Horizon |
| Nightwatch | MCP 服务器提供路由执行时间、查询耗时、作业执行指标等性能数据 |