laravel-best-practices

Enforce Laravel backend best practices across controllers, models, migrations, and routes.

1.5k|170|Updated Sep 25, 2024
One-click install
npx skills add https://github.com/relaticle/relaticle --skill laravel-best-practices-relaticle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-best-practices
Source: https://github.com/relaticle/relaticle/tree/main/.claude/skills/laravel-best-practices
Command: npx skills add https://github.com/relaticle/relaticle --skill laravel-best-practices-relaticle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill standardizes Laravel backend development by enforcing a comprehensive set of best practices across controllers, models, migrations, requests, policies, jobs, routes, and services to improve reliability and maintainability.

Core Features & Use Cases

  • Enforces correct Eloquent relationships, local scopes, form requests, and policy checks to prevent common mistakes.
  • Promotes consistent naming, route definitions, and queue configurations to reduce onboarding time and errors.
  • Supports code reviews and refactoring to elevate existing Laravel code to industry-standard patterns.

Quick Start

Refactor a sample Laravel controller to use a form request, local scope, and policy check to demonstrate the pattern.

Frequently Asked Questions about laravel-best-practices

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

FAQPage Schema
How do I prevent N+1 queries in Laravel Eloquent models?

Prevent N+1 queries in Laravel Eloquent models by enforcing correct relationship definitions and utilizing local scopes. This standardizes data retrieval patterns to optimize performance and reduce unnecessary database load during typical workloads.

What's the best way to structure Laravel controllers for maintainability?

The best way to structure Laravel controllers for maintainability is by extracting validation into form requests and authorization into policies. This standardizes backend code, reduces controller bloat, and ensures consistent separation of concerns across the application.

How do I standardize Laravel route definitions and naming conventions?

Standardize Laravel route definitions and naming conventions by enforcing consistent patterns across the application. This reduces onboarding time and prevents routing errors by ensuring all endpoints follow uniform structural rules and predictable identifiers.

Can I use Laravel best practices for refactoring existing backend code?

Yes, you can use Laravel best practices for refactoring existing backend code. The process supports code reviews by elevating current controllers, models, and jobs to industry-standard patterns, improving reliability and maintainability without rewriting the entire application.

How do I configure Laravel jobs and queues for optimal performance?

Configure Laravel jobs and queues for optimal performance by enforcing proper queue configurations and job patterns. This ensures background processing reliability and prevents common workload bottlenecks during code reviews and refactoring.

How do I enforce security checks in Laravel using policies?

Enforce security in Laravel using policies by implementing policy checks for authorization logic. This ensures that user permissions are validated consistently across controllers and resources, preventing unauthorized access and standardizing backend security practices.