PHPackages                             plin-code/laravel-clean-architecture - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. plin-code/laravel-clean-architecture

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

plin-code/laravel-clean-architecture
====================================

Laravel package for generating Clean Architecture structure

v2.0.2(2mo ago)64.0kMITPHPPHP ^8.3CI failing

Since Mar 31Pushed 2mo agoCompare

[ Source](https://github.com/plin-code/laravel-clean-architecture)[ Packagist](https://packagist.org/packages/plin-code/laravel-clean-architecture)[ RSS](/packages/plin-code-laravel-clean-architecture/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (9)Versions (4)Used By (0)

🏗️ Laravel Clean Architecture Package
=====================================

[](#️-laravel-clean-architecture-package)

A Laravel package to easily implement Clean Architecture in your projects. 🚀

[![Latest Version on Packagist](https://camo.githubusercontent.com/6a7a870c049e0c4522af6f927d6da2f1c463216437dfbfdae3bf209227f9330d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706c696e2d636f64652f6c61726176656c2d636c65616e2d6172636869746563747572652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plin-code/laravel-clean-architecture)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7b5fac2d46242c272500c1e674d77a87923479a4752d93cc00aee8387a1d8479/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c696e2d636f64652f6c61726176656c2d636c65616e2d6172636869746563747572652f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/plin-code/laravel-clean-architecture/actions?query=workflow%3ATests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/da900c28b88bfaedfd4025e9af5d5377e580da1642e5eb0e013fe898d541f4b8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c696e2d636f64652f6c61726176656c2d636c65616e2d6172636869746563747572652f636f64652d7374796c652d6669782e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/plin-code/laravel-clean-architecture/actions?query=workflow%3A%22Code+Style+%28Auto-fix%29%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1bc189f56ff77d41daa30492ef6d3f35ca0db41111ad9e72f9b4143b7db1fa80/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706c696e2d636f64652f6c61726176656c2d636c65616e2d6172636869746563747572652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/plin-code/laravel-clean-architecture)

✨ Features
----------

[](#-features)

- 🎯 **Domain-Driven Design** - Organize your code with DDD principles
- ⚡ **Quick Setup** - Get started with Clean Architecture in minutes
- 🧩 **Auto-Generation** - Generate complete domains with one command
- 🏛️ **Layer Separation** - Clear separation between Domain, Application, and Infrastructure
- 🔧 **Customizable** - Flexible configuration to fit your project needs
- 🧪 **Test-Ready** - Pre-built test templates for immediate testing
- 📚 **Well-Documented** - Comprehensive documentation and examples
- 🎨 **Modern PHP** - Built for PHP 8.3+ with latest Laravel features

📋 Requirements
--------------

[](#-requirements)

- 🐘 PHP 8.3+
- ⚡ Laravel 12.x / 13.x

📦 Installation
--------------

[](#-installation)

```
composer require plin-code/laravel-clean-architecture
```

⚙️ Configuration
----------------

[](#️-configuration)

Publish the configuration files and stubs:

```
php artisan vendor:publish --provider="PlinCode\LaravelCleanArchitecture\CleanArchitectureServiceProvider"
```

🎯 Usage
-------

[](#-usage)

### 🏗️ Installing Clean Architecture structure

[](#️-installing-clean-architecture-structure)

```
php artisan clean-arch:install
```

This command will create:

- 📁 Folder structure for Domain, Application and Infrastructure layers
- 🧩 Base classes (BaseModel, BaseAction, BaseService, etc.)
- ⚙️ Configuration file
- 📖 Documentation

### 🆕 Creating a new domain

[](#-creating-a-new-domain)

```
php artisan clean-arch:make-domain User
```

This command will generate:

- 🏛️ Domain model with events
- 📊 Status enums
- 🔔 Domain events (Created, Updated, Deleted)
- ⚡ Actions (Create, Update, Delete, GetById)
- 🔧 Service
- 🌐 API Controller
- 📝 Form Requests (Create, Update)
- 📤 API Resource
- 🗃️ Database migration
- 🧪 Feature tests

After generating the core files, `make-domain` prompts interactively for optional components. You can choose to also generate an Observer, Listener, Job, Mail, Notification, and Export for the domain. Each prompt can be answered independently, so you only generate what your domain needs.

### ✅ Architecture validation

[](#-architecture-validation)

```
php artisan clean-arch:validate
```

This command checks your codebase for layer dependency violations (for example, Domain code importing from Infrastructure). It returns exit code 1 when violations are found, making it suitable for use in CI pipelines.

```
Clean Architecture Validation
=============================

  ✓ Domain has no Application imports
  ✓ Domain has no Infrastructure imports
  ✓ Application has no Infrastructure imports
  ✓ No Observers in Domain
  ✓ No Jobs in Infrastructure
  ✓ No Commands in Infrastructure
  ✓ No duplicate Services directory

No violations found.

```

### 🛠️ Available commands

[](#️-available-commands)

- `clean-arch:install` - 🏗️ Install Clean Architecture structure
- `clean-arch:make-domain {name}` - 🆕 Create a complete new domain
- `clean-arch:make-action {name} {domain}` - ⚡ Create a new action
- `clean-arch:make-service {name}` - 🔧 Create a new service
- `clean-arch:make-controller {name}` - 🌐 Create a new controller
- `clean-arch:make-observer {name} {domain}` - 👁️ Create a new observer
- `clean-arch:make-listener {name}` - 👂 Create a new listener
- `clean-arch:make-job {name}` - ⏳ Create a new job
- `clean-arch:make-mail {name}` - 📧 Create a new mailable
- `clean-arch:make-notification {name}` - 🔔 Create a new notification
- `clean-arch:make-export {name}` - 📤 Create a new export
- `clean-arch:validate` - ✅ Validate architecture dependency rules
- `clean-arch:generate-package {name} {vendor}` - 📦 Generate a new package

### 📂 Project structure after `clean-arch:install`

[](#-project-structure-after-clean-archinstall)

```
app/
├── Domain/                          # Pure business logic
├── Application/                     # Use cases and orchestration
│   ├── Actions/
│   ├── Services/
│   ├── Jobs/
│   ├── Listeners/
│   └── Console/Commands/
└── Infrastructure/                  # Framework adapters
    ├── Http/
    │   ├── Controllers/Api/
    │   ├── Middleware/
    │   ├── Requests/
    │   └── Resources/
    ├── UI/
    ├── Mail/
    ├── Notifications/
    ├── Observers/
    ├── Exports/
    ├── Validation/
    └── Exceptions/

```

### 📂 Generated structure after `clean-arch:make-domain User`

[](#-generated-structure-after-clean-archmake-domain-user)

```
app/
├── Domain/
│   └── Users/
│       ├── Models/
│       │   └── User.php
│       ├── Enums/
│       │   └── UserStatus.php
│       └── Events/
│           ├── UserCreated.php
│           ├── UserUpdated.php
│           └── UserDeleted.php
├── Application/
│   ├── Actions/
│   │   └── Users/
│   │       ├── CreateUserAction.php
│   │       ├── UpdateUserAction.php
│   │       ├── DeleteUserAction.php
│   │       └── GetByIdUserAction.php
│   └── Services/
│       └── UserService.php
└── Infrastructure/
    └── Http/
        ├── Controllers/
        │   └── Api/
        │       └── UsersController.php
        ├── Requests/
        │   ├── CreateUserRequest.php
        │   └── UpdateUserRequest.php
        └── Resources/
            └── UserResource.php

```

🏛️ Clean Architecture Principles
--------------------------------

[](#️-clean-architecture-principles)

This package implements Clean Architecture principles:

1. **🎯 Domain Layer**: Contains business logic and entities
2. **⚡ Application Layer**: Contains use cases and application logic
3. **🏗️ Infrastructure Layer**: Contains implementation details (controllers, database, etc.)

### 🔗 Dependencies

[](#-dependencies)

- **🎯 Domain Layer**: Does not depend on any other layer
- **⚡ Application Layer**: Depends only on Domain Layer
- **🏗️ Infrastructure Layer**: Depends on Application and Domain Layers

💡 Examples
----------

[](#-examples)

### 🛍️ Creating a Product domain

[](#️-creating-a-product-domain)

```
php artisan clean-arch:make-domain Product
```

### 🎮 Using in controller

[](#-using-in-controller)

```
class ProductsController extends Controller
{
    public function __construct(
        private CreateProductAction $createProductAction,
        private ProductService $productService
    ) {}

    public function store(CreateProductRequest $request): JsonResponse
    {
        $product = $this->createProductAction->execute($request);

        return response()->json([
            'data' => new ProductResource($product),
            'message' => 'Product created successfully'
        ], 201);
    }
}
```

⚙️ Configuration
----------------

[](#️-configuration-1)

The configuration file `config/clean-architecture.php` allows you to customize:

- 🏷️ Default namespace
- 📁 Directory paths
- ✅ Validation options
- 📊 Logging settings

🛠️ Development
--------------

[](#️-development)

This package uses several tools to maintain code quality:

### 🔧 Code Quality Tools

[](#-code-quality-tools)

- **🎨 Laravel Pint** - Code formatting and style fixing
- **🔍 PHPStan** - Static analysis for finding bugs
- **🧪 PEST** - Modern testing framework built on PHPUnit
- **🎭 Orchestra Testbench** - Laravel package testing

### 📜 Available Scripts

[](#-available-scripts)

```
# 🧪 Run tests
composer test

# 📊 Run tests with coverage
composer test-coverage

# 🎨 Fix code style
composer format

# 👀 Check code style without fixing
composer format-test

# 🔍 Run static analysis
composer analyse

# ✨ Run all quality checks
composer quality
```

### 🚀 Development Setup

[](#-development-setup)

1. 📥 Clone the repository
2. 📦 Install dependencies: `composer install`
3. ✨ Run quality checks: `composer quality`

🤝 Contributing
--------------

[](#-contributing)

Pull requests are welcome! 🎉 For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate and follow our [Contributing Guidelines](CONTRIBUTING.md). 📝

📄 License
---------

[](#-license)

[MIT](https://choosealicense.com/licenses/mit/) 📜

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance85

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

80d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7653cedfb706bdbaceab17cb57fa55d5e2744faeb722cfc1e2af8c3fd88f13ef?d=identicon)[danielebarbaro](/maintainers/danielebarbaro)

---

Top Contributors

[![danielebarbaro](https://avatars.githubusercontent.com/u/4376886?v=4)](https://github.com/danielebarbaro "danielebarbaro (40 commits)")

---

Tags

phplaravelpackageDomain Driven Designdddclean architecture

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/plin-code-laravel-clean-architecture/health.svg)

```
[![Health](https://phpackages.com/badges/plin-code-laravel-clean-architecture/health.svg)](https://phpackages.com/packages/plin-code-laravel-clean-architecture)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.5k](/packages/larastan-larastan)[laravel/ai

The official AI SDK for Laravel.

9782.1M161](/packages/laravel-ai)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7212.9k](/packages/tehwave-laravel-achievements)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

4821.5k](/packages/erag-laravel-lang-sync-inertia)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

15104.9k4](/packages/calebdw-larastan)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
