Examples menu

Greeter

Click a name and the greeting changes. The page is a class with one #[Signal] property and two #[Action] methods, and the template gets them by name.

#[Signal] turns the $greeting property into a reactive signal. After an action writes $this->greeting, php-via sends the new value to the browser over 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.ref }} 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 scope initial: "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

Buttons trigger the actions; data-text shows the greeting as the signal patch arrives.