Laravel Livewire
Agent Workflow (MANDATORY)
Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:
- fuse-ai-pilot:explore-codebase - Check existing Livewire components
- fuse-ai-pilot:research-expert - Verify Livewire 3 patterns via Context7
- mcp__context7__query-docs - Check specific Livewire features
After implementation, run fuse-ai-pilot:sniper for validation.
Overview
| Feature |
Description |
| Components |
Reactive PHP classes with Blade views |
| wire:model |
Two-way data binding |
| Actions |
Call PHP methods from frontend |
| Events |
Component communication |
| Volt |
Single-file components |
| Folio |
File-based routing |
Critical Rules
- Always use wire:key in loops
- Use wire:model.blur for validation, not .live everywhere
- Debounce search inputs with .debounce.300ms
- #[Locked] for sensitive IDs
- authorize() in destructive actions
- protected methods for internal logic
Decision Guide
Component Type
Component choice?
├── Complex logic → Class-based component
├── Simple page → Volt functional API
├── Medium complexity → Volt class-based
├── Quick embed → @volt inline
└── File-based route → Folio + Volt
Data Binding
Binding type?
├── Form fields → wire:model.blur
├── Search input → wire:model.live.debounce.300ms
├── Checkbox/toggle → wire:model.live
├── Select → wire:model
└── No sync → Local Alpine x-data
Reference Guide
Core Concepts (WHY & Architecture)
| Topic |
Reference |
When to Consult |
| Components |
components.md |
Creating components |
| Wire Directives |
wire-directives.md |
Data binding, events |
| Lifecycle |
lifecycle.md |
Hooks, mount, hydrate |
| Forms |
forms-validation.md |
Validation, form objects |
| Events |
events.md |
Dispatch, listen |
| Alpine |
alpine-integration.md |
$wire, @entangle |
| File Uploads |
file-uploads.md |
Upload handling |
| Nesting |
nesting.md |
Parent-child |
| Loading |
loading-states.md |
wire:loading, lazy |
| Navigation |
navigation.md |
SPA mode |
| Testing |
testing.md |
Component tests |
| Security |
security.md |
Auth, rate limit |
| Volt |
volt.md |
Single-file components |
Advanced Features
| Topic |
Reference |
When to Consult |
| Folio |
folio.md |
File-based routing |
| Precognition |
precognition.md |
Live validation |
| Reverb |
reverb.md |
WebSockets |
Templates (Complete Code)
| Template |
When to Use |
| BasicComponent.php.md |
Standard component |
| FormComponent.php.md |
Form with validation |
| VoltComponent.blade.md |
Volt patterns |
| DataTableComponent.php.md |
Table with search/sort |
| FileUploadComponent.php.md |
File uploads |
| NestedComponents.php.md |
Parent-child |
| ComponentTest.php.md |
Testing patterns |
Quick Reference
Basic Component
class Counter extends Component
{
public int $count = 0;
public function increment(): void
{
$this->count++;
}
public function render()
{
return view('livewire.counter');
}
}
Volt Functional
<?php
use function Livewire\Volt\{state};
state(['count' => 0]);
$increment = fn() => $this->count++;
?>
<button wire:click="increment">{{ $count }}</button>
Wire Directives
<input wire:model.blur="email">
<input wire:model.live.debounce.300ms="search">
<button wire:click="save" wire:loading.attr="disabled">Save</button>
Best Practices
DO
- Use wire:key in @foreach loops
- Debounce search/filter inputs
- Use Form Objects for reusable logic
- Test with Livewire::test()
- #[Locked] for IDs, #[Computed] for derived data
DON'T
- wire:model.live on every field
- Query in render() method
- Forget authorization in actions
- Skip wire:key in loops
- Store sensitive data in public properties
Laravel 13 Notes
Livewire 4 sur Laravel 13
Livewire 4 est la version compatible Laravel 13. Changements clés :
- PHP 8.3 minimum (était 8.2 sur Livewire 3)
wire:model.live rate-limited par défaut (300ms debounce implicite)
#[Locked], #[Computed], #[On] toujours supportés
- Volt et Folio : versions majeures alignées (Volt 2, Folio 2)
- PreventRequestForgery : routes
/livewire/update gérées automatiquement, pas de config requise
Migration depuis Livewire 3
wire:poll.5s → toujours valide
$this->dispatch('event') → toujours valide
- Form Objects (
#[\Livewire\Attributes\Validate]) → API stable
1---2name: laravel-livewire3description: Livewire 4 reactive components on Laravel 13 - wire:model, actions, events, Volt, Folio. Use when building reactive UI without JavaScript.4---56<objective>7Covers Livewire 4 on Laravel 13: reactive class-based components with Blade8views, wire:model two-way binding and its modifiers (.blur, .live,9.debounce), actions, component lifecycle hooks, forms/validation, events10(dispatch/listen), Alpine.js integration ($wire, @entangle), file uploads,11component nesting, loading states, SPA navigation, testing, security12(auth/rate limiting), and the Volt (single-file components) and Folio13(file-based routing) sub-features, including Precognition live validation14and Reverb WebSocket integration.15</objective>1617# Laravel Livewire1819## Agent Workflow (MANDATORY)2021Before ANY implementation, spawn 3 agents in parallel, one `Agent` call each with a `name`:22231. **fuse-ai-pilot:explore-codebase** - Check existing Livewire components242. **fuse-ai-pilot:research-expert** - Verify Livewire 3 patterns via Context7253. **mcp__context7__query-docs** - Check specific Livewire features2627After implementation, run **fuse-ai-pilot:sniper** for validation.2829---3031## Overview3233| Feature | Description |34|---------|-------------|35| **Components** | Reactive PHP classes with Blade views |36| **wire:model** | Two-way data binding |37| **Actions** | Call PHP methods from frontend |38| **Events** | Component communication |39| **Volt** | Single-file components |40| **Folio** | File-based routing |4142---4344## Critical Rules45461. **Always use wire:key** in loops472. **Use wire:model.blur** for validation, not .live everywhere483. **Debounce search inputs** with .debounce.300ms494. **#[Locked]** for sensitive IDs505. **authorize()** in destructive actions516. **protected methods** for internal logic5253---5455## Decision Guide5657### Component Type5859```60Component choice?61├── Complex logic → Class-based component62├── Simple page → Volt functional API63├── Medium complexity → Volt class-based64├── Quick embed → @volt inline65└── File-based route → Folio + Volt66```6768### Data Binding6970```71Binding type?72├── Form fields → wire:model.blur73├── Search input → wire:model.live.debounce.300ms74├── Checkbox/toggle → wire:model.live75├── Select → wire:model76└── No sync → Local Alpine x-data77```7879---8081## Reference Guide8283### Core Concepts (WHY & Architecture)8485| Topic | Reference | When to Consult |86|-------|-----------|-----------------|87| **Components** | [components.md](references/components.md) | Creating components |88| **Wire Directives** | [wire-directives.md](references/wire-directives.md) | Data binding, events |89| **Lifecycle** | [lifecycle.md](references/lifecycle.md) | Hooks, mount, hydrate |90| **Forms** | [forms-validation.md](references/forms-validation.md) | Validation, form objects |91| **Events** | [events.md](references/events.md) | Dispatch, listen |92| **Alpine** | [alpine-integration.md](references/alpine-integration.md) | $wire, @entangle |93| **File Uploads** | [file-uploads.md](references/file-uploads.md) | Upload handling |94| **Nesting** | [nesting.md](references/nesting.md) | Parent-child |95| **Loading** | [loading-states.md](references/loading-states.md) | wire:loading, lazy |96| **Navigation** | [navigation.md](references/navigation.md) | SPA mode |97| **Testing** | [testing.md](references/testing.md) | Component tests |98| **Security** | [security.md](references/security.md) | Auth, rate limit |99| **Volt** | [volt.md](references/volt.md) | Single-file components |100101### Advanced Features102103| Topic | Reference | When to Consult |104|-------|-----------|-----------------|105| **Folio** | [folio.md](references/folio.md) | File-based routing |106| **Precognition** | [precognition.md](references/precognition.md) | Live validation |107| **Reverb** | [reverb.md](references/reverb.md) | WebSockets |108109### Templates (Complete Code)110111| Template | When to Use |112|----------|-------------|113| [BasicComponent.php.md](references/templates/BasicComponent.php.md) | Standard component |114| [FormComponent.php.md](references/templates/FormComponent.php.md) | Form with validation |115| [VoltComponent.blade.md](references/templates/VoltComponent.blade.md) | Volt patterns |116| [DataTableComponent.php.md](references/templates/DataTableComponent.php.md) | Table with search/sort |117| [FileUploadComponent.php.md](references/templates/FileUploadComponent.php.md) | File uploads |118| [NestedComponents.php.md](references/templates/NestedComponents.php.md) | Parent-child |119| [ComponentTest.php.md](references/templates/ComponentTest.php.md) | Testing patterns |120121---122123## Quick Reference124125### Basic Component126127```php128class Counter extends Component129{130 public int $count = 0;131132 public function increment(): void133 {134 $this->count++;135 }136137 public function render()138 {139 return view('livewire.counter');140 }141}142```143144### Volt Functional145146```php147<?php148use function Livewire\Volt\{state};149150state(['count' => 0]);151152$increment = fn() => $this->count++;153?>154155<button wire:click="increment">{{ $count }}</button>156```157158### Wire Directives159160```blade161<input wire:model.blur="email">162<input wire:model.live.debounce.300ms="search">163<button wire:click="save" wire:loading.attr="disabled">Save</button>164```165166---167168## Best Practices169170### DO171- Use wire:key in @foreach loops172- Debounce search/filter inputs173- Use Form Objects for reusable logic174- Test with Livewire::test()175- #[Locked] for IDs, #[Computed] for derived data176177### DON'T178- wire:model.live on every field179- Query in render() method180- Forget authorization in actions181- Skip wire:key in loops182- Store sensitive data in public properties183184---185186## Laravel 13 Notes187188### Livewire 4 sur Laravel 13189Livewire 4 est la version compatible Laravel 13. Changements clés :190191- **PHP 8.3 minimum** (était 8.2 sur Livewire 3)192- `wire:model.live` rate-limited par défaut (300ms debounce implicite)193- `#[Locked]`, `#[Computed]`, `#[On]` toujours supportés194- Volt et Folio : versions majeures alignées (Volt 2, Folio 2)195- **PreventRequestForgery** : routes `/livewire/update` gérées automatiquement, pas de config requise196197### Migration depuis Livewire 3198- `wire:poll.5s` → toujours valide199- `$this->dispatch('event')` → toujours valide200- Form Objects (`#[\Livewire\Attributes\Validate]`) → API stable