frontend-patterns

Standardize Laravel frontend architecture with Blade, Livewire, and Alpine.js.

Updated Jan 6, 2023
One-click install
npx skills add https://github.com/pekral/phpstan-rules --skill frontend-patterns-pekral
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-patterns
Source: https://github.com/pekral/phpstan-rules/tree/main/.claude/skills/frontend-patterns
Command: npx skills add https://github.com/pekral/phpstan-rules --skill frontend-patterns-pekral

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses the complexity of managing state and performance in modern Laravel applications, preventing common pitfalls like N+1 queries, bloated components, and inconsistent UI behavior.

Core Features & Use Cases

  • Component Composition: Provides patterns for building clean, reusable Blade components using slots and attributes instead of rigid inheritance.
  • State Management: Defines clear boundaries for state placement between Livewire (server-side) and Alpine.js (client-side) to ensure optimal performance and responsiveness.
  • Performance Optimization: Includes strategies for eager loading, lazy rendering, and efficient form handling to keep applications fast and scalable.

Quick Start

Use the frontend-patterns skill to refactor a complex Livewire component by extracting business logic into an Action and moving ephemeral UI state into Alpine.

Frequently Asked Questions about frontend-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I manage state between Livewire and Alpine.js in Laravel frontend components?

Laravel frontend component state should be split by boundary: Livewire manages server-side state for database interactions, while Alpine.js handles ephemeral client-side UI state. This division ensures optimal performance and responsiveness without unnecessary server round-trips.

What's the best way to structure reusable Blade components without rigid inheritance?

Blade components should be built using composition with slots and attributes rather than relying on rigid inheritance hierarchies. This pattern creates clean, reusable UI components that are easier to maintain and test within Laravel applications.

How do I prevent N+1 queries and performance issues in Livewire components?

Performance issues in Livewire components are prevented by applying eager loading strategies, lazy rendering techniques, and efficient form handling patterns. These optimizations keep Laravel applications fast and scalable during interactive web interface rendering.

When should I refactor a Livewire component by extracting business logic into Actions?

Refactoring a Livewire component by extracting business logic into an Action class is necessary when component bloat occurs or server-side state management becomes complex. Moving ephemeral UI state to Alpine.js simultaneously streamlines the component.

Does this frontend architecture pattern require specific Laravel packages or dependencies?

The architecture pattern standardizes Laravel UI development using Blade, Livewire, and Alpine.js without requiring additional packages or dependencies. It focuses on component composition, server-side state management, and efficient database interaction patterns natively.

What problems does standardizing Laravel frontend architecture solve?

Standardizing Laravel frontend architecture solves the complexity of managing state and performance, preventing common pitfalls like N+1 queries, bloated components, and inconsistent UI behavior in modern Laravel applications.