laravel-best-practices

Guide Laravel 12 development with architecture, Eloquent, and security best practices.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/helmordev/ecom-app --skill laravel-best-practices-helmordev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-best-practices
Source: https://github.com/helmordev/ecom-app/tree/main/.agents/skills/laravel-best-practices
Command: npx skills add https://github.com/helmordev/ecom-app --skill laravel-best-practices-helmordev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and scripts (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance and enforces best practices for developing scalable, maintainable, and secure Laravel 12 applications, reducing common pitfalls and improving code quality.

Core Features & Use Cases

  • Architecture Guidance: Promotes patterns like service classes, repository patterns, and feature folders for organized code.
  • Eloquent Optimization: Enforces efficient database interactions through eager loading and proper query scoping.
  • Secure Coding: Highlights security best practices like mass assignment protection and input validation.
  • Use Case: When building a new feature in a Laravel application, consult this Skill to ensure controllers are thin, business logic is in services, and database queries are optimized.

Quick Start

Apply the laravel-best-practices skill when creating a new Eloquent model to ensure it follows best practices for relationships and casting.

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 to keep business logic out of them?

To follow Laravel best practices, keep controllers thin by moving business logic into dedicated service classes and repositories. This separation ensures your application remains maintainable and scalable as it grows.

What is the best way to prevent N+1 query problems in Laravel Eloquent?

Prevent N+1 query problems in Laravel Eloquent by applying eager loading. This best practice optimizes database interactions by loading relationships upfront, significantly improving application performance.

How do I secure Laravel applications against mass assignment vulnerabilities?

Secure Laravel applications against mass assignment by defining fillable properties on Eloquent models. This best practice ensures only explicitly allowed fields are updated, protecting your application from malicious input.

When should I use feature folders instead of default directories for Laravel architecture?

Use feature folders for Laravel architecture when building complex applications to group related files by domain. This pattern promotes organized code and maintainability compared to standard default directory structures.

Does this Laravel best practices guide apply to API design and validation?

Yes, this guide covers API design and validation by enforcing modern PHP and Laravel patterns. It provides comprehensive rules for secure input validation and scalable API endpoint construction.

Why should I refactor existing Laravel projects to use service classes?

Refactor existing Laravel projects to use service classes to isolate business logic from controllers. This architectural best practice reduces common pitfalls, improves code quality, and makes maintenance easier.