Examples menu

๐Ÿ‘‹ Greeter

Composition API: one #[Signal] property and two #[Action] methods. The closure handler becomes a small class โ€” the template is unchanged.

#[Signal] turns the $greeting property into a reactive signal. Writing to $this->greeting inside an action auto-syncs the new value to the browser via SSE.
#[Action] marks greetBob() and greetAlice() as client-callable. Both write to the same $greeting property with different values.
Auto-injection โ€” the template reads {{ greeting.id }} and {{ greetBob.url }} with no view data passed for them. Signals and actions are injected by name automatically.
Zero JavaScript โ€” every button click fires a server round-trip via Datastar. The response patches only the changed signal, not the whole page.

Greeting: Hello...

โšก Signals

greeting string TAB Hello...

#[Signal] property. The displayed greeting message; both actions write to it.

๐ŸŽฏ Actions

greetBob

#[Action] method. Sets $this->greeting to "Hello Bob!".

greetAlice

#[Action] method. Sets $this->greeting to "Hello Alice!".

๐Ÿ‘ Views

greeter.html.twig

Unchanged from the closure version โ€” buttons trigger the actions; the greeting updates reactively via SSE patch.