PHPackages                             yntech/domain-forge - 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. [Framework](/categories/framework)
4. /
5. yntech/domain-forge

ActiveLibrary[Framework](/categories/framework)

yntech/domain-forge
===================

Hexagonal architecture generator for Laravel. Provides Artisan commands for structuring domains following the principles of DDD and Screaming Architecture.

v3.1.0(3mo ago)128MITPHPPHP ^8.2

Since Mar 13Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Allmacht/domain-forge)[ Packagist](https://packagist.org/packages/yntech/domain-forge)[ RSS](/packages/yntech-domain-forge/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

Domain Forge
============

[](#domain-forge)

[![Latest Version](https://camo.githubusercontent.com/3242dfd8f1989f862138374eecf46bbe0000ac8910d9ded1e8b12eb050420427/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796e746563682f646f6d61696e2d666f7267652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yntech/domain-forge)[![Total Downloads](https://camo.githubusercontent.com/c0220104fdfd512bbddd256eee3356993df21c09f3d140fdf96b77a75c30c961/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796e746563682f646f6d61696e2d666f7267652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yntech/domain-forge)[![License](https://camo.githubusercontent.com/73f7b778182ecd853bb09bbc96a37f4ad02ea7ea175f1e5fa1abd739f5fbc0d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f796e746563682f646f6d61696e2d666f7267652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yntech/domain-forge)

Domain Forge is a powerful Laravel package that streamlines the creation of domain modules following **Hexagonal Architecture** (Ports &amp; Adapters) and **Domain-Driven Design (DDD)** principles. Generate complete, production-ready domain structures with a single command.

🌟 Features
----------

[](#-features)

- ✅ **Complete DDD Structure** - Automatically generates Application, Domain, and Infrastructure layers
- ✅ **Value Objects** - Rich domain models with validation and type safety
- ✅ **Native PHP Enums** - First-class support for PHP 8.1+ enums with helper methods
- ✅ **Auto-generated IDs** - Smart UUID/ULID generation for entity identifiers
- ✅ **Type Safety** - Nullable types, primitives, and enum support
- ✅ **Customizable Stubs** - Publish and modify templates to fit your needs
- ✅ **Automatic Mappers** - Eloquent ↔ Domain entity mappers
- ✅ **Smart Validation** - Password hashing, timestamp handling, and more
- ✅ **Rollback Support** - Automatic cleanup on errors
- ✅ **Permission Checks** - Validates write permissions before generation

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

[](#-requirements)

- PHP 8.1 or higher
- Laravel 10.x or 11.x or higher
- Composer

🚀 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require yntech/domain-forge
```

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

[](#️-configuration)

### 1. Configure Base Structure

[](#1-configure-base-structure)

Run the installation command to set up the base structure:

```
php artisan domain-forge:install
```

### 2. Update Composer Autoload

[](#2-update-composer-autoload)

Add the following to your `composer.json` in the `autoload.psr-4` section:

```
{
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Src\\": "src/"
        }
    }
}
```

### 3. Refresh Autoload

[](#3-refresh-autoload)

```
composer dump-autoload
```

📚 Usage
-------

[](#-usage)

### Basic Domain Generation

[](#basic-domain-generation)

Create a simple domain module:

```
php artisan domain-forge:domain User
```

This generates:

```
src/Contexts/User/
├── Application/
│   ├── Commands/
│   ├── Handlers/
│   ├── DTOs/
│   ├── Services/
│   └── UseCases/
├── Domain/
│   ├── Entities/
│   │   └── User.php
│   ├── Contracts/
│   │   └── UserRepositoryContract.php
│   ├── Exceptions/
│   └── ValueObjects/
└── Infrastructure/
    ├── Http/
    │   ├── Controllers/
    │   ├── Requests/
    │   ├── Resources/
    │   └── Routes/
    │       └── User.php
    ├── Persistence/
    │   ├── Mappers/
    │   └── Repositories/
    │       └── Eloquent/
    │           └── UserRepository.php
    └── UserServiceProvider.php

```

### Domain with Properties

[](#domain-with-properties)

Generate a domain with value objects:

```
php artisan domain-forge:domain Product --props="name:string,price:float,stock:int,description:?string"
```

**Generated Value Objects:**

- `ProductName` (string)
- `ProductPrice` (float)
- `ProductStock` (int)
- `ProductDescription` (nullable string)

**Entity Structure:**

```
