Download the PHP package creativecrafts/laravel-domain-driven-design-lite without Composer

On this page you can find all versions of the php package creativecrafts/laravel-domain-driven-design-lite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-domain-driven-design-lite

Latest Version on Packagist GitHub Tests Action Status Code Style Total Downloads

Pragmatic, Laravel-native DDD modules with generators, safety rails, and CI helpers – without drowning you in ceremony.


✅ Quick Start (60s)


📚 Contents

🧩 Start Here

If you only read three sections:

🧭 What is DDD-Lite?

DDD-Lite is a developer-tooling package that helps you organise your Laravel 12+ application into modular, domain-oriented boundaries.

It gives you:

The goal is: clean seams, safer refactors, better testability – without requiring you to rewrite your entire app in one go.


🧱 Architecture Overview

A DDD-Lite module lives under modules/<ModuleName>:

✅ Rules of thumb

Domain:

App:

⚙️ Requirements

Recommended dev dependencies in your app (for quality tooling integration):

⚙️ Installation

Require the package in your Laravel app (usually as a dev dependency):

This package is primarily a developer tool (scaffolding, conversion, quality helpers), so installing under --dev is recommended. Laravel’s package discovery will automatically register the service provider.

📦 Provider & Publishing

DDD-Lite ships with stubs and quality configs you can copy into your app.

Stubs (module scaffolding & generators)

To publish the stubs:

This will create:

You typically don’t need to touch these unless you want to customise the generated code style.

Quality tooling

To seed PHPStan, Deptrac and Pest architecture tests into your application:

This will (in your app):

Safe publishing tip

You can also publish selectively:

Customising stubs (recommended workflow)

1) Publish the stubs once:

2) Edit the generated files under stubs/ddd-lite/ in your app (e.g. tweak DTO or controller templates). 3) Re-run the generator command. Your customised stubs are now the source of truth.

Tip: keep your stub changes small and version-controlled so upgrades are easy to diff.

✅ Enforcing Strict Architecture with Deptrac + PHPStan

This package ships publishable templates you can wire into your app to enforce module boundaries and strict layered architecture.

1) Publish the configs

This creates (in your app):

2) Deptrac: strict module boundaries

The template already defines layers like Http, Models, Repositories, Domain, Providers, and ModulesAll. To enforce stricter module boundaries, extend the ruleset to constrain Modules\*\Domain and Modules\*\App explicitly.

Example (add to deptrac.app.yaml):

For cross‑module rules, add a shared kernel (e.g. Modules\Shared) and only allow ModuleDomain to depend on Modules\Shared (not other modules).

3) PHPStan: include modules and tighten strictness

The published phpstan.app.neon already includes:

To go stricter, set level: max and enable stricter checks:

4) CI integration

Use the existing Composer scripts:

⚠️ Limitations: Circular Dependencies at Scale

🚀 Getting Started (QuickStart)

We’ll build a simple Planner module with a Trip aggregate.

1) Scaffold a module

This creates modules/Planner with:

Core flags:

For full details see: docs/module-scaffold.md

2) Generate a DTO

This generates modules/Planner/Domain/DTO/CreateTripData.php:

3) Generate a domain Action

This creates Domain/Actions/Trip/CreateTripAction.php similar to:

4) Implement the repository & bind it Create an Eloquent repository in modules/Planner/App/Repositories/TripRepository.php (or let ddd-lite:make:repository scaffold it):

Then wire the contract to the implementation:

ddd-lite:bind edits your module provider so that:

is registered.

5) Expose via HTTP Generate a controller + request:

✅ Recipes

Recipes index

Controller Orchestrates a Domain Action (HTTP stays in App)

This is the missing piece most people want: the controller only adapts HTTP input and delegates to the Domain action. The action stays HTTP‑free.

1) Generate the pieces

2) Domain action (pure business logic)

3) Form request (HTTP concerns only)

4) Controller (orchestrates, no business logic)

5) Minimal feature test (verifies orchestration)

Boundary rule of thumb: App layer knows HTTP; Domain layer never does.

Payments Module Walkthrough (DTO → Contract → Repository → Action)

This compact slice ties the pieces together with real code, while keeping Domain pure and App infrastructural.

1) Generate the artifacts

2) DTO (Domain)

3) Contract (Domain)

4) Repository (App, Eloquent adapter)

5) Action (Domain, orchestrates business rules)

Boundary rule of thumb: Domain owns the contract and action; App wires the implementation and persistence.

🧠 DDD-Lite in Practice: Example Flow

A typical “vertical slice” in a module:

Generators help you keep this shape consistent across modules without hand-rolling boilerplate every time.

✅ Advanced Workflows

Multi‑Tenant SaaS Structure + Boundary Enforcement (Deptrac + PHPStan)

This section shows a concrete, enforceable layout for multi‑tenant apps, with shared domain concepts and strict module boundaries.

1) Recommended module layout

2) Shared Kernel (domain‑only) Use --shared to keep it pure (no HTTP/Routes):

3) Shared domain concepts (example)

4) Tenancy boundary (example contract)

5) App layer adapter uses tenancy, Domain stays pure

✅ Deptrac: Enforce Module Boundaries

Create a deptrac.yaml in your host app (this repo ships a package example, but apps should define their own rules):

6) Run Deptrac with DDD‑Lite

✅ PHPStan: Block Cross‑Module Dependencies

Add module‑level ban rules in your app’s phpstan.neon to prevent accidental imports:

Then override per‑module configs (example for Projects):

Boundary rule of thumb: Domains depend only on Shared + their own contracts. App layer can orchestrate across modules via contracts and adapters.

Limitations & Mitigations (circular dependencies)

Shared concepts + cross‑module communication (tenant‑safe patterns)

Tenant isolation guidelines

Safe Refactor Workflow with --dry-run + Rollback

Use dry‑run previews and manifests to refactor large features into modules safely.

1) Plan the move (no files written)

Syntax reminders

2) Apply moves with review (writes manifest)

The output includes a manifest id:

3) Inspect what was changed

Each action records the file path and the type (create/update/move).

How to read dry‑run output

4) Rollback if needed

5) Refactor with dry‑run safety (scaffold + bind)

6) Verification checklist

Error handling tips

Before/After tree (concrete example)

Before (legacy feature in app/):

After (moved into modules/Billing):

Convert Monolith app/ → Invoicing Module (with namespace rewrites)

This is the complete, safe workflow: scaffold the module first, then plan + apply moves.

1) Scaffold the module (required)

2) Plan the conversion (no files written)

3) Review and apply moves (writes manifest)

4) Confirm namespace rewrites

5) Rollback if needed

Notes

Create an Orders Module + Typical Structure

1) Create the module

2) Typical directory structure (Domain vs App)

3) Register + adapter example The module provider is created and registered automatically during ddd-lite:module. To connect App infrastructure to Domain, bind a contract in the module provider:

Then use the contract inside a Domain action, while App implementations remain Eloquent‑based.

4) Minimal flow (Controller → Action → Repository)

🧭 Project Initialization

For a guided, one‑shot setup (stubs, quality configs, optional module, and CI snippet):

Common flags:

🧰 Command Reference

All commands share a consistent UX:

Command Index

Cheat Sheet

Goal Command
Initialize a project php artisan ddd-lite:init --module=Core --publish=all --ci=show
Create a module skeleton php artisan ddd-lite:module Billing
Generate a DTO php artisan ddd-lite:make:dto Billing CreateInvoiceData --props="id:Ulid,title:string"
Create an Action php artisan ddd-lite:make:action Billing CreateInvoice --in=Invoice --input=FQCN
Bind a contract php artisan ddd-lite:bind Billing InvoiceRepositoryContract InvoiceRepository
Plan legacy moves php artisan ddd-lite:convert Billing --plan-moves --paths=app/Models
Apply moves safely php artisan ddd-lite:convert Billing --apply-moves --review
Suggest contracts php artisan ddd-lite:convert Billing --plan-moves --suggest-contracts
Publish quality tooling php artisan ddd-lite:publish:quality --target=all
Run structural checks php artisan ddd-lite:doctor --module=Billing
List modules + health php artisan ddd-lite:modules:list --with-health

1. Module scaffolding & conversion

ddd-lite:module Scaffold a new module skeleton:

Key flags:

See docs/module-scaffold.md for details.

ddd-lite:convert Discover and optionally apply moves from app/* into modules:

To use the namespace rewriting and AST-based moves, install nikic/php-parser:

composer require --dev nikic/php-parser

Important options:

Use this to gradually migrate a legacy app into DDD-Lite modules.

Safe conversion workflow

2. Domain generators

ddd-lite:make:dto Generate a DTO under Domain/DTO:

ddd-lite:make:action Generate a domain action in Domain/Actions:

ddd-lite:make:contract Generate a domain contract:

ddd-lite:make:repository Generate an Eloquent repository for an aggregate:

Creates:

ddd-lite:make:value-object Generate a value object:

By default, a test is created at: modules/<Module>/tests/Unit/Domain/ValueObjects/<Name>Test.php

Example: Email value object with validation (egulias/email-validator)

1) Install the validator in your app:

2) Generate the value object:

3) Update the generated file:

Path: modules/Users/Domain/ValueObjects/Email.php

4) Instantiate in your Domain layer (e.g. in an Action):

5) Add a minimal test (Pest):

Path: modules/Users/tests/Unit/EmailTest.php

ddd-lite:make:aggregate-root Generate an aggregate root base:

Useful for richer domain modelling around key aggregates.

Query side

Example:

3. App-layer generators

ddd-lite:make:model Generate an Eloquent model in App/Models:

Options:

ddd-lite:make:migration Generate a migration under Database/migrations:

ddd-lite:make:controller Generate a controller:

ddd-lite:make:request Generate a form request:

4. Binding & wiring

ddd-lite:bind Bind a domain contract to an implementation in the module provider:

5. Manifest commands Every write operation (scaffolding, generate, convert, publish, doctor fixes) is tracked via a Manifest.

ddd-lite:manifest:list List manifests:

Options:

ddd-lite:manifest:show Inspect a single manifest:

Shows the tracked operations for that run (created files, backups, moves, deletions, etc.).

6. Doctor & Quality commands

ddd-lite:publish:quality (Described earlier) – publishes PHPStan, Deptrac, and Pest Arch configuration/stubs into your app.

ddd-lite:doctor Run structural checks on your modules and wiring:

Checks things like:

Flags:

ddd-lite:doctor:domain Run domain purity checks via Deptrac:

Options:

ddd-lite:doctor-ci Run both structural and domain checks in CI:

Use this in your CI pipeline to enforce module health.

ddd-lite:boundaries Alias for ddd-lite:doctor:domain to run Deptrac boundary checks with a friendlier name.

ddd-lite:modules:list List modules and (optionally) show health:

ddd-lite:stubs:diff Compare package stubs to your customized stubs:

ddd-lite:stubs:sync Sync missing or changed stubs into your app:

🧪 Safety Rails: Manifest & Rollback

DDD-Lite never silently edits your app.

For each command run that changes files:

This makes DDD-Lite safe to use on large, existing codebases.

🧮 Package Quality: PHPStan, Deptrac & Pest

Inside this package:

In your application, use:

and then:

Combine this with ddd-lite:doctor-ci in CI for a tight feedback loop.

🧩 Common Workflows

Greenfield project

Migrating a legacy app

🧪 Testing Philosophy

The package itself is tested with:

You’re encouraged to:

🔒 Design Principles

🧰 Troubleshooting

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security

Please review our security policy on how to report security vulnerabilities.

🙌 Credits

📄 License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-domain-driven-design-lite with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/filesystem Version ^12.0|^13.0
symfony/uid Version ^7.3|^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package creativecrafts/laravel-domain-driven-design-lite contains the following files

Loading the files please wait ...