laravel-best-practices

Standardize Laravel 13 architecture, Eloquent, validation, security, and API design.

Updated Aug 6, 2025
One-click install
npx skills add https://github.com/devghor/h2-hrms --skill laravel-best-practices-devghor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-best-practices
Source: https://github.com/devghor/h2-hrms/tree/main/.ai/skills/laravel-best-practices
Command: npx skills add https://github.com/devghor/h2-hrms --skill laravel-best-practices-devghor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Laravel 13 best-practices provide a structured, authoritative guide to standardize architecture, Eloquent usage, validation, security, and API design across Laravel projects.

Core Features & Use Cases

  • Architecture & structure guidance (service classes, single-purpose actions, DTOs, repositories) to improve maintainability and testability.
  • Eloquent patterns (eager loading, scopes, casts, relationships) to optimize database access and code readability.
  • Validation and form requests best practices, including rule organization, authorization, and security considerations.
  • API design patterns (resources, versioning, consistent responses) for scalable APIs and client integration.
  • Real-world use cases including new apps, refactors, and team onboarding to accelerate delivery.

Quick Start

Apply the Laravel 13 best-practices guidelines to your project by auditing controllers, models, requests, and services and implementing the recommended patterns.

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 Laravel controllers and services for better maintainability?

Laravel architecture best practices recommend using service classes, single-purpose action classes, and DTOs to standardize controllers. This separation improves maintainability and testability by moving business logic out of controllers and into dedicated service layers.

What is the best way to optimize Eloquent queries and prevent the N+1 problem in Laravel?

Eloquent optimization best practices involve using eager loading, model scopes, and custom casts. Applying these patterns standardizes database access, reduces unnecessary queries, and significantly improves code readability across your Laravel application.

How do I organize validation rules and authorization in Laravel API projects?

Laravel validation best practices prescribe using form requests for rule organization and authorization. This approach secures applications by separating validation logic from controllers and ensuring robust security considerations before data processing.

Does this Laravel best practices guide cover API design and versioning for scalable apps?

Yes, the guide covers API design patterns including API resources, versioning, and consistent responses. These standardized patterns support scalable APIs and streamline client integration for new applications and refactoring projects.

Can I use these Laravel 13 guidelines for team onboarding and project refactoring?

Yes, these Laravel 13 best practices target project onboarding, refactoring, and scalable team workflows. They provide a structured, authoritative guide to standardize architecture, security, and Eloquent usage across modern PHP 8.3 projects.

When should I use repositories versus single-purpose actions in Laravel architecture?

The guide recommends repositories for complex data access patterns and single-purpose actions for isolated tasks. Choosing between them depends on whether your team needs generalized querying or specific, testable business operations.