> ## 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 年 6 月 Laravel 更新

> 2026 年 6 月 Laravel 生態系更新。Bus::bulk()、Postgres 交易 pooler 支援、MCP 用戶端／伺服器、artisan dev 指令、路由中繼資料等。

2026 年 6 月 Laravel Cloud 開始支援 Symfony 應用，Forge 新增 Managed Valkey 快取與物件儲存。框架方面則帶來批次 Job dispatch、Postgres pooler 支援、MCP 用戶端／伺服器等豐富更新。

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

***

## Laravel Framework

### Bus::bulk() — 批次 Job dispatch

現在可用 1 次 DB INSERT 註冊大量 Job。每個佇列與連線都會做批次 INSERT，因此不再需要一筆一筆 INSERT 的成本。

```php theme={null}
use Illuminate\Support\Facades\Bus;

Bus::bulk([
    new ProcessOrder($order1),
    new ProcessOrder($order2),
    new ProcessOrder($order3),
    // 數千件也很有效率
]);
```

### 支援 Postgres 交易 Pooler

框架層級支援 PgBouncer、AWS RDS Proxy、Neon 等交易模式的 Postgres 連線 pooler。

```php theme={null}
// config/database.php
'pgsql' => [
    'driver' => 'pgsql',
    'pooled' => true,  // 宣告為透過 pooler 連線
    // ...
],
```

<Info>
  若需要直接連線的 schema 操作或 DDL 等，可在連線名稱後加上 `::direct` 以繞過 pooler。
  `DB::connection('pgsql::direct')->statement('CREATE INDEX ...')`
</Info>

框架會自動處理 emulated prepares、boolean binding 等 pooler 所需的所有處理。

### MCP 用戶端與伺服器 Tool 支援

Laravel AI Agent 可利用遠端 MCP 伺服器（透過 HTTP）與本地 MCP 伺服器類別的 tool。schema 轉換、包裝、呼叫全部自動處理。

```php theme={null}
class MyAgent extends Agent
{
    public function tools(): array
    {
        return [
            // 使用遠端 MCP 伺服器的 tool
            McpClient::tools('https://mcp.example.com'),
            // 使用本地 MCP 伺服器的 tool
            McpServer::tools(MyMcpServer::class),
        ];
    }
}
```

### artisan dev 指令

新增 `artisan dev`，可用一個指令啟動所有開發流程。伺服器、佇列 worker、日誌 tail、Vite 會以帶顏色的輸出同時運作。

```bash theme={null}
php artisan dev
```

```php theme={null}
// 於 Service Provider 註冊額外指令
use Illuminate\Foundation\Console\DevCommands;

DevCommands::artisan('reverb:start', 'reverb')->orange();
DevCommands::register('stripe listen --forward-to ' . config('app.url'))->green();
```

<Tip>
  會自動偵測 Node.js 套件管理器（npm、yarn、pnpm、bun）。這是 Artisan 的官方慣例，取代過去的 `composer dev` 腳本。
</Tip>

### 路由中繼資料支援

新增可為路由附加任意中繼資料的 `->metadata()` 方法。它完全相容於路由快取，於群組上設定的中繼資料會被合併到子路由。

```php theme={null}
Route::metadata(['head' => ['robots' => ['noindex'], 'author' => 'Taylor']])
    ->group(function () {
        Route::get('/users', [UserController::class, 'index'])
            ->metadata(['head' => ['title' => 'Users']]);
    });

// 從 Controller 或 middleware 存取
$request->route()->getMetadata('head.title');          // 'Users'
$request->route()->getMetadata('head.author', 'Taylor'); // 'Taylor'
```

### 不再重試的例外處理

對於重試無意義的例外（不正確輸入、持續性的外部故障等），可以停用重試。

```php theme={null}
// 直接在例外類別定義
class InvalidInputException extends RuntimeException
{
    public function retry(): bool
    {
        return false;
    }
}

// 也可以在 bootstrap/app.php 設定
->withExceptions(function (Exceptions $exceptions) {
    $exceptions->dontRetry(InvalidInputException::class);
})
```

### schema:dump 的 --without-migration-data flag

`schema:dump` 可產生不含 migration 表資料、純粹的結構 dump。

```bash theme={null}
php artisan schema:dump --without-migration-data
```

### between()/unlessBetween() 的時區修正

無論在 `between()` 或 `unlessBetween()` 之前或之後呼叫 `timezone()`，排程都能以正確的時區運作。

```php theme={null}
// 兩者行為相同（過去把 between 寫在前面時會誤用 UTC）
$schedule->command('foo')->timezone('Europe/Rome')->between('10:00', '12:00');
$schedule->command('foo')->between('10:00', '12:00')->timezone('Europe/Rome');
```

### 其他框架變更

* **`Bus::bulk()` 支援 trait**：可在 trait 中定義佇列屬性
* **MariaDB 向量索引**：MariaDB 支援向量索引
* **`attachFromStorage()` helper**：通知的 `MailMessage` 可從 storage 加入附件
* **`Cache::rememberWithState()`**：支援帶狀態的快取
* **平行測試用維護模式 driver**：`array` driver 可讓各程序具有獨立的維護狀態
* **`whenFilledEnum()`**：以 Enum 為基礎的欄位條件處理
* **JSON Schema 的 anyOf 支援**：驗證可使用 JSON Schema 的 `anyOf`

***

## Inertia

* **`Client\Request::uri()`**：取得 client 請求的 URI
* **`<a>` 標籤的 `target` 屬性支援**：`<Link>` 元件可使用 `target="_blank"` 等
* **表單 `async` 選項**：表單元件支援非同步送出
* **`titleCallback` 帶入頁面資訊**：title callback 會收到頁面資料

***

## Laravel Cloud、Laravel Forge

| 產品                | 主要更新                                                                                               |
| ----------------- | -------------------------------------------------------------------------------------------------- |
| **Laravel Cloud** | 完整支援 Symfony 應用（Symfony 7.4 LTS、8.x，PHP 8.2〜8.5）、支援從 Stripe Projects 部署與付款、可依團隊成員設定 Slack/Email 通知 |
| **Laravel Forge** | Managed Valkey 快取（可從儀表板建立與管理）、Managed 物件儲存、通知信件改版                                                  |


## Related topics

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