laravel-architecture

Enforce multi-layer Laravel architecture across controllers, services, repositories, and requests.

Updated Jul 13, 2023
One-click install
npx skills add https://github.com/changgenglu/changgenglu-blog --skill laravel-architecture-changgenglu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-architecture
Source: https://github.com/changgenglu/changgenglu-blog/tree/main/prompt_engineering/agents/skills/laravel-architecture
Command: npx skills add https://github.com/changgenglu/changgenglu-blog --skill laravel-architecture-changgenglu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a structured, best-practice guide for implementing a clean Laravel multi-layer architecture, ensuring clear responsibilities and easier maintainability across Controller, Service, Repository.

Core Features & Use Cases

  • Defines a recommended separation of concerns across Controller, FormRequest, Service, Repository, and Model layers.
  • Provides naming conventions and dependency injection bindings to support DIP and testability.
  • Useful during feature design, refactoring, or architecture reviews to ensure consistent architecture decisions.

Quick Start

Apply these Laravel architecture guidelines when designing a new feature to ensure proper layering and naming conventions.

Frequently Asked Questions about laravel-architecture

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

FAQPage Schema
What is the best way to structure a Laravel application for maintainability?

The best way to structure Laravel for maintainability is enforcing a multi-layer architecture. This separates concerns across Controller, FormRequest, Service, Repository, and Model layers to ensure clear responsibilities.

How do I implement a service layer and repository pattern in Laravel?

Implement a service layer and repository pattern by defining separation of concerns across controllers, services, and repositories. Use standardized naming conventions and dependency injection bindings to support the dependency inversion principle.

When should I use a multi-layer architecture instead of standard Laravel MVC?

Use a multi-layer architecture instead of standard Laravel MVC during feature design, refactoring, or architecture reviews. It becomes necessary when you need strict separation of concerns and improved testability for maintainable code.

How do I bind repositories to services using dependency injection in Laravel?

Bind repositories to services using dependency injection by applying standardized dependency injection bindings. This supports the dependency inversion principle and enhances testability across your Laravel application's architectural layers.

Does a clean architecture approach work with existing Laravel FormRequest validation?

A clean architecture approach works seamlessly with existing Laravel FormRequest validation. The multi-layer structure defines specific responsibilities for FormRequest layers alongside controllers, services, repositories, and models.

What naming conventions should I follow for Laravel repository and service classes?

Follow standardized naming conventions for Laravel repository and service classes to ensure consistent architecture decisions. These conventions standardize file layout and class naming across the controller, service, and repository layers.