v1 LiVue v1 is here — server-driven reactivity for Laravel using Vue.js Get Started →

Composables

Composables Showcase: PHP Namespaces

Auto-discovered use* methods with composableState() and callable actions.

How it works

The component uses trait methods named use*. LiVue auto-discovers them as PHP composables and exposes namespaced data/actions in the template (for example cart.add(), cart.increment()).

Cart count (composable)

Server time (meta)

Component id

Composable actions ready

  • (qty: )
  • No items yet.
app/LiVue/Composables/UseShowcaseCart.php
public function useCart(): array
{
    $state = $this->composableState('cart', ['items' => [], 'nextId' => 1]);

    return [
        'items' => $state['items'],
        'add' => function(string $label) use ($state) { ... },
    ];
}
resources/views/livue/php-composables-demo.blade.php
<button @click="cart.add(draftLabel)">Add</button>
<button @click="cart.increment(item.id)">+ qty</button>
<button v-click="resetFromPhp">Reset from PHP</button>