Skip to main content

Overview

Lyger Livewire provides a server-side reactive component system that allows you to build dynamic interfaces without writing JavaScript. Components automatically handle updates, events, and state management.
Lyger Livewire is inspired by Laravel Livewire but built specifically for the Lyger framework with full integration support.

Creating Components

1

Create Component Class

Extend the Lyger\Livewire\Component base class and implement the render() method:
2

Register Component

Register your component with the Livewire manager:
3

Use in Views

Include the component in your views using the component name:

Component Lifecycle

Mount Method

The mount() method is called when a component is first created:

Public Properties

All public properties are automatically tracked and synced with the frontend:

Data Binding

Properties are automatically synchronized between the server and client:

Validation

Components include built-in validation support:

Error Handling

Events

Emit events to communicate between components:

Component Traits

Lyger Livewire includes reusable traits for common functionality:

WithEvents

WithFileUploads

WithPagination

WithSearch

Actions and Methods

Calling Methods

Component methods can be called from the frontend:

Redirects

Example usage:

Authentication

Components have built-in authentication helpers:

Request Handling

The Livewire Manager handles incoming AJAX requests:
The Manager automatically handles component instantiation, property updates, and method execution based on the request payload.

Best Practices

1

Keep Components Focused

Each component should have a single responsibility. Break complex UIs into smaller, reusable components.
2

Use Public Properties Wisely

Only make properties public if they need to be tracked and synced. Use protected/private for internal state.
3

Validate User Input

Always validate data before processing, especially for security-sensitive operations.
4

Handle Errors Gracefully

Use try-catch blocks and provide meaningful error messages to users.
5

Optimize Rendering

Cache expensive computations and avoid unnecessary database queries in the render method.

API Reference

Component Methods

Manager Methods