laravel-best-practices

Guide Laravel 12 projects with structured best practices for architecture, Eloquent, and APIs.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/JefersonCCJM/hotel_san_pedro --skill laravel-best-practices-jefersonccjm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-best-practices
Source: https://github.com/JefersonCCJM/hotel_san_pedro/tree/main/.agents/skills/laravel-best-practices
Command: npx skills add https://github.com/JefersonCCJM/hotel_san_pedro --skill laravel-best-practices-jefersonccjm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Laravel projects often drift into inconsistent architectures, tangled controllers, and fragile validation. This Skill provides a structured, rule-based guide to applying Laravel 12 best practices across architecture, Eloquent, controllers, validation, and API design.

Core Features & Use Cases

  • Architecture & Structure: service classes, single-purpose action classes, DTOs, repositories, value objects, events, and feature folders for domain-driven organization.
  • Eloquent & Database: eager loading, query scopes, model events, and clean data access patterns to improve performance and maintainability.
  • Controllers & Routing: RESTful resource controllers, form requests, dependency injection, and API resources for consistent endpoints.
  • Validation & Security: centralized validation via Form Requests, authorization, and mass-assignment protections.
  • API Design & Testing: versioning, resources, pagination, and testable patterns to support scalable APIs.

Quick Start

Implement Laravel 12 best practices in your project's controllers, models, and APIs to keep code clean and scalable.

Frequently Asked Questions about laravel-best-practices

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

FAQPage Schema
How do I structure a Laravel project to avoid tangled controllers and inconsistent architecture?

To structure a Laravel project effectively, use service classes, single-purpose action classes, DTOs, and feature folders. This domain-driven organization separates concerns, keeping controllers clean and your application architecture maintainable.

What are the best practices for Laravel Eloquent to improve database performance?

Laravel Eloquent best practices for performance include using eager loading to prevent N+1 queries, applying query scopes for clean data access, and leveraging model events. These patterns ensure efficient database interactions and maintainable code.

How do I centralize validation and authorization in Laravel API development?

Centralize Laravel validation by using Form Requests, which also handle authorization rules. This approach secures your API endpoints against mass-assignment vulnerabilities and keeps controllers focused on business logic.

Does this Laravel best practices guide support building scalable RESTful APIs?

Yes, this guide supports scalable RESTful APIs by recommending API versioning, API resources for consistent data mapping, pagination, and testable patterns. These practices ensure endpoints remain robust and easy to maintain as applications grow.

When should I use repositories versus service classes in Laravel architecture?

Use service classes for orchestrating business logic and single-purpose action classes for specific tasks, while repositories handle data access patterns. This separation in Laravel architecture prevents code duplication and improves overall testability.