PHPackages                             incoder/laravel-ddd - 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. [API Development](/categories/api)
4. /
5. incoder/laravel-ddd

ActiveLibrary[API Development](/categories/api)

incoder/laravel-ddd
===================

Domain-Driven Design (DDD) Library for Laravel

1.0.1(2mo ago)031MITPHPPHP ^8.3CI passing

Since Apr 30Pushed 2mo agoCompare

[ Source](https://github.com/rbsgaridan/laravel-ddd)[ Packagist](https://packagist.org/packages/incoder/laravel-ddd)[ RSS](/packages/incoder-laravel-ddd/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (16)Versions (3)Used By (0)

Incoder Laravel DDD
===================

[](#incoder-laravel-ddd)

Reusable Laravel DDD / Clean Architecture building blocks packaged for Composer.

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/ef0054230522e542bc1f908ac005c6c75888dea255bac910f9015e12095e31d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c7565)](https://php.net)[![Laravel Version](https://camo.githubusercontent.com/c286e7eb6afe54ec820728b171488f49a7fad47a4fae4b4d6d7be1dd82753e95/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531322e32312d726564)](https://laravel.com)

Overview
--------

[](#overview)

`incoder-ddd` provides shared foundations for Laravel applications that use a Domain / Application / Infrastructure split. The package includes:

- base entities and aggregate roots
- repository abstractions and Eloquent repository bases
- application service and DTO bases
- attribute-based route scanning
- AppService auto-route registration
- OpenAPI / Swagger generation
- TypeScript proxy generation
- Flutter OpenAPI proxy generation
- SSRS reporting helpers

The package is installable as a standalone Composer library and registers itself through Laravel package auto-discovery.

Developer Manual
----------------

[](#developer-manual)

For a fuller consumer guide, see [docs/DEVELOPER-MANUAL.md](/C:/laravel-projects/packages/incoder-ddd/docs/DEVELOPER-MANUAL.md).

Package Name
------------

[](#package-name)

Current `composer.json` package name:

```
composer require incoder/laravel-ddd
```

Requirements
------------

[](#requirements)

- PHP `^8.3`
- `illuminate/support` `^12.21`
- `illuminate/database` `^12.21`
- `ramsey/uuid`
- `spatie/laravel-data`
- `spatie/laravel-activitylog`

Installation
------------

[](#installation)

Install the package in a Laravel application:

```
composer require incoder/laravel-ddd
```

Laravel will discover `Incoder\DDD\Support\IncoderDDDServiceProvider` automatically.

Optional publish steps:

```
php artisan vendor:publish --tag=api-docs
php artisan vendor:publish --tag=incoder-ddd-config
```

This publishes:

- `config/incoder-ddd.php`
- `config/api-docs.php`
- `config/reporting.php`

What The Package Actually Assumes
---------------------------------

[](#what-the-package-actually-assumes)

Some features are generic. Some are opinionated and default to conventions already encoded in this package.

Those defaults now live in `config/incoder-ddd.php`.

Default conventions:

- AppService discovery expects classes under `Core\Application\...`
- DI auto-binding expects `Core\Domain\...` and `Core\Infrastructure\Eloquent\Repositories\...`
- controller route scanning reads `app/Http/Controllers`
- scaffold commands generate files into `core/...`
- AppService HTTP routes are registered under `/app/api/{service}`

If your application does not follow those conventions, you can override the package defaults in `config/incoder-ddd.php`. The generic base classes remain reusable even when you disable or replace convention-based scanning.

Core Building Blocks
--------------------

[](#core-building-blocks)

### Domain Entities

[](#domain-entities)

Use `Entity`, `AggregateRoot`, or `AuthenticableAggregateRoot` as base classes for domain models.

```
use Incoder\DDD\Domain\Entities\Entity;
use Incoder\DDD\Support\Attributes\FillableAttribute;

class Department extends Entity
{
    protected $table = 'departments';

    public $incrementing = true;
    protected $keyType = 'int';

    #[FillableAttribute]
    protected string $name;
}
```

Confirmed behavior from the codebase:

- soft deletes are enabled on `Entity`
- `#[FillableAttribute]` drives fillable-property detection
- string keys generate UUIDs on create
- activity logging is wired through `spatie/laravel-activitylog`

### DTO Base

[](#dto-base)

`Incoder\DDD\Application\DTOs\DTOBase` extends `Spatie\LaravelData\Data` and provides `toDTO()` / `toDTOs()` helpers for Eloquent models.

### Repository Base

[](#repository-base)

Repository contracts extend `Incoder\DDD\Domain\Repositories\IRepository`. Eloquent implementations can build on:

- `Incoder\DDD\Infrastructure\Repositories\EloquentRepository`
- `Incoder\DDD\Infrastructure\Repositories\EloquentRepositoryBase`

### AppService Base

[](#appservice-base)

`Incoder\DDD\Application\Services\AppServiceBase` provides CRUD-oriented application service helpers and is the base type used by AppService route / OpenAPI / proxy scanning.

The inherited default AppService middleware comes from `AppServiceBase`:

- `api`
- `auth:sanctum`

You can override class-wide route middleware with `#[AppServiceMiddleware(...)]`.

Routing
-------

[](#routing)

### Controller Attribute Routing

[](#controller-attribute-routing)

`#[RouteAttribute]` can be used on controller methods. If no middleware is supplied:

- `/api/...` and `/app/api/...` routes default to `api`
- other routes default to `web`

Example:

```
use Incoder\DDD\Support\Attributes\RouteAttribute;

#[RouteAttribute(methods: ['GET'], uri: '/reports', name: 'reports.index')]
public function index()
{
}
```

### AppService Auto-Routes

[](#appservice-auto-routes)

Classes that:

- are in the Composer classmap
- live under `Core\Application\...`
- end with `AppService`
- extend `AppServiceBase`

are auto-registered at boot under `/app/api/{service}`.

Supported patterns:

- CRUD conventions: `getAll`, `getPaged`, `getById`, `create`, `update`, `delete`
- custom routes with `#[RouteAttribute]`
- convention routes based on HTTP verb prefixes like `getActiveUsers` or `postArchive`

Permission integration is available through `#[RequiresPermission(...)]` if your app provides a compatible `permission` middleware alias such as the one from `spatie/laravel-permission`.

More detail: [docs/features/APPSERVICE-ROUTES.md](docs/features/APPSERVICE-ROUTES.md)

OpenAPI / Swagger
-----------------

[](#openapi--swagger)

The package can generate an OpenAPI spec from auto-registered AppServices and exposes Swagger UI in non-production environments when `config('api-docs.enabled')` is true.

Default routes:

- UI: `/api/docs`
- spec: `/api/docs/spec`

Generate a spec file:

```
php artisan api:generate-spec
php artisan api:generate-spec --format=yaml --output=public/api-docs.yaml
php artisan api:generate-spec --stdout
```

More detail: [docs/features/OPENAPI-DOCS.md](docs/features/OPENAPI-DOCS.md)

Proxy Generation
----------------

[](#proxy-generation)

### TypeScript

[](#typescript)

Generate TypeScript service proxies and DTO/schema models from the discovered AppServices:

```
php artisan proxy:generate
php artisan proxy:generate --output=resources/js/proxies
```

Default output path is `resources/js/proxies`. You can also override it in `config/incoder-ddd.php`.

### Flutter

[](#flutter)

Generate Flutter/Dart OpenAPI sources via the OpenAPI Generator CLI:

```
php artisan proxy:generate-flutter \
  --flutter-root=../flutter \
  --output=../flutter/lib/src/generated/openapi \
  --config=../flutter/tool/openapi-generator-config.yaml \
  --jar=../flutter/.tooling/openapi-generator/openapi-generator-cli-7.21.0.jar
```

The Flutter generator expects:

- a sibling Flutter project by default
- Java
- an OpenAPI Generator CLI JAR at the configured path

Scaffolding Commands
--------------------

[](#scaffolding-commands)

### Create a Domain Model Scaffold

[](#create-a-domain-model-scaffold)

```
php artisan make:domain-model User --type=aggregate --format=string --incrementing=false --schema=admin
```

### Create Model Only

[](#create-model-only)

```
php artisan make:domain-model Employee --type=entity --format=int --incrementing=true --schema=admin --only-model
```

### Create CRUD Around an Existing Model

[](#create-crud-around-an-existing-model)

```
php artisan make:domain-crud User --schema=admin --format=string --incrementing=false
```

Important: these commands currently generate into `core/...` directories and `Core\...` namespaces in the consuming application.

Reporting
---------

[](#reporting)

The package includes SSRS reporting support through:

- `Incoder\DDD\Support\Reporting\Contracts\IReportService`
- `Incoder\DDD\Support\Reporting\Facades\Report`

Supported operations:

- `generatePdfReport()`
- `streamPdfReport()`
- `getReportInfo()`
- `testConnection()`

Required environment variables for reporting:

```
SSRS_BASE_URL=http://your-ssrs-server/ReportServer
SSRS_USERNAME=your_username
SSRS_PASSWORD=your_password
SSRS_TIMEOUT=120
SSRS_CACHE_TTL=0
```

More detail: [docs/features/README-REPORTING.md](docs/features/README-REPORTING.md)

Development Notes
-----------------

[](#development-notes)

- This repository is a Composer package, not a full Laravel app.
- Package behavior should remain stable for Composer consumers.
- If you change command names, config keys, publish tags, route conventions, generated output, or service-provider behavior, treat that as a public API change.

Useful checks:

```
composer validate --no-check-publish
composer dump-autoload
```

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance83

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~0 days

Total

2

Last Release

85d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/55342596?v=4)[!nc0d3r](/maintainers/rbsgaridan)[@rbsgaridan](https://github.com/rbsgaridan)

---

Top Contributors

[![rbsgaridan](https://avatars.githubusercontent.com/u/55342596?v=4)](https://github.com/rbsgaridan "rbsgaridan (8 commits)")

---

Tags

laravelopenapiDomain Driven Designdddclean architecture

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/incoder-laravel-ddd/health.svg)

```
[![Health](https://phpackages.com/badges/incoder-laravel-ddd/health.svg)](https://phpackages.com/packages/incoder-laravel-ddd)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M133](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[illuminate/queue

The Illuminate Queue package.

20432.6M1.7k](/packages/illuminate-queue)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M136](/packages/laravel-pulse)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)

PHPackages © 2026

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