
Laravel Patterns
Apply production Laravel layering—controllers, services/actions, Eloquent, APIs, queues, events, and caching—in new or growing PHP backends.
Overview
Laravel Patterns is an agent skill for the Build phase that applies production Laravel architecture—routing, Eloquent, services, queues, and API resources—for maintainable backends.
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill laravel-patternsWhat is this skill?
- Layer boundaries: HTTP controllers → services/actions → Eloquent models
- Explicit and scoped route model bindings with authorization still enforced
- Typed models, casts, and query scopes for consistent domain logic
- Queues, events, and caching for IO-heavy and expensive reads
- API resources, form requests, policies, and config centralized under config/*
Adoption & trust: 4.9k installs on skills.sh; 210k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Laravel app is growing with bloated controllers, scattered domain logic, and unclear API and async boundaries.
Who is it for?
Indie builders building Laravel web apps or JSON APIs who want agent-guided structure aligned with common production practice.
Skip if: Non-PHP stacks, front-end-only SPAs without a Laravel backend, or greenfield projects where you have not chosen Laravel yet.
When should I use this skill?
Building Laravel web applications or APIs; structuring controllers, services, and domain logic; working with Eloquent, API resources, queues, events, or caching.
What do I get? / Deliverables
New and refactored code follows a conventional layered layout with validation, resources, policies, and queues placed where Laravel teams expect them.
- Layered app/ structure with Actions, Services, Requests, Resources
- Route and model binding patterns with policy hooks
- Queue, event, and cache placement guidance applied to features
Recommended Skills
Journey fit
Laravel architecture guidance applies while you are constructing the product backend, not during launch SEO or production incident response. Backend subphase is the canonical home for routing, domain models, service layers, and API resources.
How it compares
Opinionated Laravel layering guide—not generic REST design or a DevOps deploy pipeline skill.
Common Questions / FAQ
Who is laravel-patterns for?
Solo developers and small teams shipping Laravel applications or APIs who want consistent architecture patterns while coding with an agent.
When should I use laravel-patterns?
Use it in Build on the backend when structuring controllers and services, designing Eloquent models and APIs, or adding queues, events, and caching.
Is laravel-patterns safe to install?
It is documentation-style guidance without mandatory external calls; review the Security Audits panel on this Prism page like any third-party skill.
SKILL.md
READMESKILL.md - Laravel Patterns
# Laravel Development Patterns Production-grade Laravel architecture patterns for scalable, maintainable applications. ## When to Use - Building Laravel web applications or APIs - Structuring controllers, services, and domain logic - Working with Eloquent models and relationships - Designing APIs with resources and pagination - Adding queues, events, caching, and background jobs ## How It Works - Structure the app around clear boundaries (controllers -> services/actions -> models). - Use explicit bindings and scoped bindings to keep routing predictable; still enforce authorization for access control. - Favor typed models, casts, and scopes to keep domain logic consistent. - Keep IO-heavy work in queues and cache expensive reads. - Centralize config in `config/*` and keep environments explicit. ## Examples ### Project Structure Use a conventional Laravel layout with clear layer boundaries (HTTP, services/actions, models). ### Recommended Layout ``` app/ ├── Actions/ # Single-purpose use cases ├── Console/ ├── Events/ ├── Exceptions/ ├── Http/ │ ├── Controllers/ │ ├── Middleware/ │ ├── Requests/ # Form request validation │ └── Resources/ # API resources ├── Jobs/ ├── Models/ ├── Policies/ ├── Providers/ ├── Services/ # Coordinating domain services └── Support/ config/ database/ ├── factories/ ├── migrations/ └── seeders/ resources/ ├── views/ └── lang/ routes/ ├── api.php ├── web.php └── console.php ``` ### Controllers -> Services -> Actions Keep controllers thin. Put orchestration in services and single-purpose logic in actions. ```php final class CreateOrderAction { public function __construct(private OrderRepository $orders) {} public function handle(CreateOrderData $data): Order { return $this->orders->create($data); } } final class OrdersController extends Controller { public function __construct(private CreateOrderAction $createOrder) {} public function store(StoreOrderRequest $request): JsonResponse { $order = $this->createOrder->handle($request->toDto()); return response()->json([ 'success' => true, 'data' => OrderResource::make($order), 'error' => null, 'meta' => null, ], 201); } } ``` ### Routing and Controllers Prefer route-model binding and resource controllers for clarity. ```php use Illuminate\Support\Facades\Route; Route::middleware('auth:sanctum')->group(function () { Route::apiResource('projects', ProjectController::class); }); ``` ### Route Model Binding (Scoped) Use scoped bindings to prevent cross-tenant access. ```php Route::scopeBindings()->group(function () { Route::get('/accounts/{account}/projects/{project}', [ProjectController::class, 'show']); }); ``` ### Nested Routes and Binding Names - Keep prefixes and paths consistent to avoid double nesting (e.g., `conversation` vs `conversations`). - Use a single parameter name that matches the bound model (e.g., `{conversation}` for `Conversation`). - Prefer scoped bindings when nesting to enforce parent-child relationships. ```php use App\Http\Controllers\Api\ConversationController; use App\Http\Controllers\Api\MessageController; use Illuminate\Support\Facades\Route; Route::middleware('auth:sanctum')->prefix('conversations')->group(function () { Route::post('/', [ConversationController::class, 'store'])->name('conversations.store'); Route::scopeBindings()->group(function () { Route::get('/{conversation}', [ConversationController::class, 'show']) ->name('conversations.show'); Route::post('/{conversation}/messages', [MessageController::class, 'store']) ->name('conversation-messages.store'); Route::get('/{conversation}/me