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

# 事件

> 說明如何運用 Laravel Copilot SDK 觸發的 Laravel 事件，於日誌收集、除錯、非同步處理中使用。

## Laravel 事件

由於在各處放入了 [Events](https://github.com/invokable/laravel-copilot-sdk/tree/main/src/Events) 內的事件類別，可用於日誌與除錯。

雖然 [hook](/zh-TW/packages/laravel-copilot-sdk/hooks) 也能達成類似效果，但事件也能在沒有 hook 的地方運作。

```text theme={null}
src/
├── Events/
│   ├── Client/
│   │   ├── ClientStarted.php
│   │   ├── ToolCall.php
│   │   └── PingPong.php
│   ├── JsonRpc/
│   │   ├── MessageReceived.php
│   │   ├── MessageSending.php
│   │   └── ResponseReceived.php
│   ├── Process/
│   │   └── ProcessStarted.php
│   └── Session/
│       ├── CreateSession.php
│       ├── MessageSend.php
│       ├── MessageSendAndWait.php
│       ├── SessionEventReceived.php
│       └── ResumeSession.php
```

例如，可將較耗時的處理丟給佇列或 `defer`。此時 `Copilot::run()` 的結果無法直接接收，但可改由 `MessageSendAndWait` 事件的 listener 接收。

```php theme={null}
dispatch(fn() => Copilot::run(''));
```

```php theme={null}
use function Illuminate\Support\defer;

defer(fn() => Copilot::run(''));
```

<Info>
  最新資訊請參考 [GitHub 儲存庫](https://github.com/invokable/laravel-copilot-sdk)。
</Info>


## Related topics

- [Laravel Reverb](/zh-TW/reverb.md)
- [電子郵件驗證（Email Verification）](/zh-TW/verification.md)
- [Laravel AI SDK](/zh-TW/ai-sdk.md)
- [Laravel Passkeys 初步調查（passkeys-server + @laravel/passkeys）](/zh-TW/blog/passkeys-introduction.md)
- [事件與監聽器](/zh-TW/events.md)
