> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# 2026 年 5 月 Laravel 更新

> 2026 年 5 月 Laravel 生態系更新。@fonts Blade 指令、Interruptible Job、Subagent 支援、Cloud 的 Scale-to-Zero 等。

2026 年 5 月，Laravel Cloud 帶來全端 Scale-to-Zero 與 Managed Queues、字型最佳化、多 Agent pipeline 等實用的大型更新。

參考來源：[Laravel May Product Updates](https://laravel.com/blog/laravel-may-product-updates)

***

## Laravel Framework

### @fonts Blade 指令

新增 `@fonts` 指令，可自動處理載入 Web 字型所需的 `<link rel="preload">` 標籤、`@font-face` 樣式與 HTTP/2 push 標頭。它會讀取 Vite 字型 plugin 產生的字型清單，一次注入必要的元素。

```blade theme={null}
{{-- 載入所有字型 --}}
@fonts

{{-- 只載入特定字型 family --}}
@fonts(["sans", "mono"])
```

<Tip>
  `@fonts` 可對每個頁面精確控制所需字型，避免不必要的 preload，並最佳化效能。
</Tip>

### Interruptible Jobs（可回應訊號的 Job）

透過新的 `Interruptible` 介面，佇列 worker 在部署期間收到 SIGTERM 時 Job 可以做出反應，能在 worker 關閉前安全地停止迴圈、釋放鎖、儲存狀態等。

```php theme={null}
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。

### storage 快取儲存

新增 `storage` 快取儲存。使用檔案系統作為快取後端，同時可利用 Laravel 的儲存設定。

```php theme={null}
// config/cache.php
'stores' => [
    'storage' => [
        'driver' => 'storage',
        'disk' => 'local',
        'path' => 'framework/cache',
    ],
],
```

### 大型 SQS payload 存至磁碟

新增選項讓 SQS 的 payload 過大時（超過 256KB）能存到磁碟。處理大量資料的佇列時很有用。

### 排程指令的環境篩選

`schedule:list` 指令可依環境進行篩選。

```bash theme={null}
php artisan schedule:list --environment=production
```

### Worker 的 Stop When Empty 選項

新增 `--stop-when-empty` 選項，佇列變空時自動停止 worker。適合批次處理或 CI 環境中，希望佇列空了就結束的 worker。

```bash theme={null}
php artisan queue:work --stop-when-empty
```

### foreignUuidFor schema helper

新增 `foreignIdFor()` 的 UUID 版本 `foreignUuidFor()`。

```php theme={null}
Schema::table('posts', function (Blueprint $table) {
    $table->foreignUuidFor(User::class)->constrained();
});
```

***

## AI Subagent 支援

Laravel AI Agent 可以委派給其他 Agent。從 `tools()` 方法回傳任意 Agent，父 Agent 的 LLM 就會像呼叫一般 tool 一樣呼叫它。由於 context 會被隔離，對話紀錄不會混雜。

```php theme={null}
class OrchestratorAgent extends Agent
{
    public function tools(): array
    {
        return [
            new AnalysisAgent(),
            new WritingAgent(),
            new SearchTool(),
        ];
    }
}
```

***

## Inertia 3.x

* **`router.poll` 的 `mode` 選項**：可設定 polling 的行為模式
* **`usePoll` 支援動態資料**：polling 期間可動態更新資料
* **`Inertia.once`**：支援只觸發一次的事件
* **`<Deferred>` 的 `rescue` slot**：deferred prop 失敗時的 fallback

***

## PAO（PHP Agentic Output）

啟動套件預設整合 PAO，並新增以下功能：

* **支援 Rector**：PAO 也會處理 Rector 的 JSON 輸出
* **PHPStan 的 Agent 引導**：加入把錯誤位置修正方法傳達給 Agent 的引導
* **`PAO_FORCE` 環境變數**：強制啟用 PAO 模式
* **Artisan RECTOR 支援**：PAO 對應 Artisan 指令

***

## Laravel Cloud、Laravel Forge、Nightwatch

| 產品                | 主要更新                                                                                                     |
| ----------------- | -------------------------------------------------------------------------------------------------------- |
| **Laravel Cloud** | 全端 Scale-to-Zero（500ms 內啟動、快 20 倍）、Managed Queues（自動擴縮 worker、失敗 Job 儀表板）、支出限制、方案更新（月費 \$5 的 Starter 方案） |
| **Laravel Forge** | Managed MySQL 8.4（自動備份、Read Replica、警示）、PHP 8.5 改為預設、env 變更時自動重啟 Horizon                                 |
| **Nightwatch**    | MCP 伺服器提供路由執行時間、查詢時間、Job 執行等效能指標                                                                         |


## Related topics

- [2026 年 3 月 Laravel 更新](/zh-TW/blog/changelog/202603.md)
- [2026 年 4 月 Laravel 更新](/zh-TW/blog/changelog/202604.md)
- [2026 年 6 月 Laravel 更新](/zh-TW/blog/changelog/202606.md)
- [Laravel 新程式碼分析生態系 — surveyor / ranger / roster](/zh-TW/blog/laravel-ecosystem-analysis.md)
- [Laravel 13 新功能彙總](/zh-TW/blog/laravel-13-new-features.md)
