livewire / volt

Volt is an elegantly crafted functional API for Livewire.
https://livewire.laravel.com/docs/volt
MIT License
339 stars 19 forks source link

[Docs]: Develop Livewire package with Volt #92

Closed robsontenorio closed 7 months ago

robsontenorio commented 7 months ago

Currently there is no direction about how to develop a package using Volt component. Is it possible?

Using regular Livewire component it works.

image

And about Volt?

inmanturbo commented 7 months ago

It won't work. You have to call volt::mount from your package's service provider to mount your package's livewire directory.

You will have to wrap it inside $this->app-> booted() or something like that to get it to happen after volt is mounted inside the main app, and merge in the existing mount paths. Something like this:

$voltPaths = collect(Volt::paths())->map(function ($path) {
    return $path->path;
})->toArray();

$paths = array_merge($voltPaths, __DIR__. '/../resources/views/livewire');

Volt::mount($paths);

Sorry for any typos. On my phone.

inmanturbo commented 7 months ago

See https://github.com/livewire/volt/issues/87

inmanturbo commented 7 months ago

Alternatively, you could direct those who use your package to add your package's directory paths to the call to volt::mount() in their volt service provider.

driesvints commented 7 months ago

Thanks @inmanturbo