Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Livewire Use Laravel Package

foxws/livewire-use

foxws/livewire-use is a Laravel Livewire package by Foxws that makes it easy to reuse and compose component logic with a simple, expressive API. It reduces boilerplate, keeps Livewire components clean and testable, and integrates seamlessly into existing Laravel and Livewire projects.

View on GitHub
Deep Wiki
Context7

Getting Started

Install and verify compatibility first.

composer require foxws/livewire-use
composer show foxws/livewire-use   # version, requires, autoload

Before writing a single line of code, check composer.json inside vendor/foxws/livewire-use for the livewire/livewire constraint. This package targets Livewire 3 conventions; if you are still on Livewire 2 the traits will not boot correctly. Also check extra.laravel.providers — most utility packages of this shape ship no service provider and no config file, in which case installation is nothing more than the composer require.

Where to look first. Because the package has zero stars and zero dependents, treat the README as a marketing blurb and the source as the documentation:

ls vendor/foxws/livewire-use/src
rg "^(trait|abstract class|class) " vendor/foxws/livewire-use/src
rg "function boot|function initialize|function mount" vendor/foxws/livewire-use/src

That last command is the most important one — it tells you which traits hook into the Livewire lifecycle and therefore which ones can silently interfere with your component.

First use case. Do not adopt the whole collection at once. Pick the single trait that solves a problem you already have (typically cached/computed properties, query-string syncing, polling, or dirty-state guards), apply it to one component, and exercise that component end to end:

use Foxws\LivewireUse\Concerns\SomeTrait; // confirm exact namespace from src/

class SearchPosts extends Component
{
    use SomeTrait;

    public string $term = '';
}

Then run the page, hit the interactive parts, and refresh once to confirm the behavior survives a full request. If it does, keep going; if not, you have lost ten minutes instead of a sprint.

Implementation Patterns

Compose, don't scatter. The sustainable pattern with a low-traffic utility package is to create a thin application-level trait or base component that composes the package traits, so the dependency appears in exactly one place:

namespace App\Livewire\Concerns;

trait UsesLivewireUtilities
{
    use \Foxws\LivewireUse\Concerns\TraitA;
    use \Foxws\LivewireUse\Concerns\TraitB;
}

When the package is abandoned or a trait changes shape, you edit one file rather than forty components.

Trait-per-concern in components. Utilities in this family usually fall into recognizable buckets: cached/computed derived state, URL query-string binding, polling and refresh intervals, unsaved-changes and dirty tracking, model resolution shortcuts, and small testing helpers. Apply each trait only to the components that need it. A component that only needs query-string sync should not inherit polling behavior it will never use — every trait you use is code that runs (or at least is reflected on) for every request to that component.

Pair each trait with a regression test. Livewire makes this cheap:

Livewire::test(SearchPosts::class)
    ->set('term', 'laravel')
    ->assertSet('term', 'laravel')
    ->assertSee('...');

Write the test at the moment you adopt the trait, while you still know what "correct" means. With no dependents upstream, your test suite is the package's test suite.

Pin the version and review diffs on upgrade. Use "foxws/livewire-use": "1.0.*" rather than a floating constraint. Before bumping, run composer diff or open the changelog; with no community bug reports to lean on, a silent behavioral change in a boot hook is a real risk.

Vendor selectively if the surface is small. If src/ contains three useful traits and a dozen experimental ones, copying the useful ones into app/Support under MIT is often cheaper than carrying the dependency. This is especially true for traits that are purely internal helpers with no external coupling.

Gotchas and Tips

  • Lifecycle hook collisions are the top failure mode. Traits that define mount(), hydrate(), boot(), updated(), or updatedFoo() will conflict with identically named methods on your component. PHP raises a fatal error on trait-trait collisions but silently lets the component's own method win over a trait method — which means a trait's mount logic can vanish without warning. Grep for these before adopting.
  • boot{TraitName} / initialize{TraitName} are the safe hooks. Livewire calls boot on every request including AJAX updates and mount only on the initial render. A trait that caches in mount but expects fresh state on subsequent updates will look broken in confusing ways. When debugging, log inside both and compare.
  • dd() inside a trait kills the response. Livewire interactions are AJAX; dumping mid-request produces a broken payload and a silent no-op in the browser. Use logger(), ray(), or Telescope. If you must dump, wrap it in an if (app()->isLocal()) and inspect the network tab.
  • Cached computed state does not invalidate itself. If a trait memoizes derived values, mutating a related model outside the component will leave stale output. Find the invalidation/flush method in the source and call it from updated() where relevant.
  • Query-string sync leaks state into URLs. Anything the trait pushes to the query string is shareable, bookmarkable, and indexable. Check whether it respects #[Url(except: ...)] and keep filters that are user-identifying or sensitive out of the synced set.
  • Class methods override trait methods. This is your primary extension point: if a trait's default behavior is almost right, redefine that method in the component and call your own logic. Verify with a quick dd(__METHOD__) that your override is actually the one running.
  • Public property defaults from traits must be serializable. Livewire 3 requires typed public properties; a trait declaring an untyped or object-typed public property will blow up on hydration. If you see "Property type not supported", look at the trait's property declarations first.
  • No provider means no config. If vendor:publish lists nothing for this package, don't go hunting for a config file — configuration is done by overriding methods or passing arguments, not by editing a published array.
  • Zero dependents means zero field reports. Budget time for reading the source rather than assuming documented behavior. If the package later disappears from Packagist, the vendored-copy fallback described above is your exit strategy.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource