- How do I install lava83/laravel-ddd?
- Install it with Composer using composer require lava83/laravel-ddd and let Laravel package discovery register the package service provider. The package is opt-in, so it does not bind paginators or publish configuration unless you use those features. After installation, run the Artisan generators to scaffold your first domain and its entities, value objects and repositories.
- What Artisan generators does laravel-ddd provide?
- The package ships generators for domains, entities, value objects and repositories, so you scaffold a bounded context instead of creating folders manually. Each generated domain gets its own service provider and a layered structure for domain, application and infrastructure code. Repository generators produce an interface plus an Eloquent-backed implementation you can swap or fake in tests.
- How does laravel-ddd separate domain, application and infrastructure layers?
- It gives each bounded context a layered structure so domain logic, application use cases and infrastructure concerns live in separate namespaces. Entities, value objects and repository interfaces stay decoupled from HTTP and Eloquent, with framework-specific code pushed into infrastructure. PSR-4 autoloading is configured per bounded context, so domain code is not mixed into a flat app directory.
- How does automatic service provider registration per domain work?
- Each domain generated by the package includes its own service provider, and the package registers those providers automatically. That means repository bindings and other domain wiring are available without editing config/app.php for every context. You still control what each provider binds, so you can replace an Eloquent repository with a fake or an alternative implementation.
- Can I use laravel-ddd in an existing Laravel application?
- Yes. The package is additive: it scaffolds new domain layers alongside your existing app code, and you can migrate features into bounded contexts incrementally. Existing controllers, models and routes keep working while you move business logic behind entities, value objects and repository interfaces. Nothing forces a full rewrite on day one.
- How do I test a laravel-ddd project?
- Because entities, value objects and domain services are decoupled from HTTP and Eloquent, you can unit test them with plain PHPUnit without booting Laravel. Repository interfaces let you substitute in-memory fakes in application-layer tests. Only infrastructure tests need a Laravel test case and a database, which keeps the fast part of your suite fast.
- Does laravel-ddd support cursor pagination for read models?
- Yes. ReadModelCursorPaginator handles Eloquent query-backed lists, and ApiCursorPageMapper with RelayedCursorPaginator handles API-backed lists. Both return Illuminate\Pagination\CursorPaginator, so controller signatures, Resource::collection(), response factories and Scramble docs stay unchanged. Existing DB-only and cursor consumers see no change because the new pieces are opt-in.
- How does laravel-ddd handle API-backed lists and remote repositories?
- For API-backed lists, the package relays the upstream cursor token verbatim through RelayedCursorPaginator rather than decoding and re-encoding it. The mapper is deliberately strict: a missing data or meta key, non-integer per_page, missing cursor keys or a non-Laravel token throws instead of silently rendering an empty last page. For remote aggregate persistence, the 0.8.0 write path requires ApiClient binding, authenticator wiring and FQCN aliasing, while the relayed read path needs no service-provider work at all.
- What production risks should I watch for with laravel-ddd?
- The main new risk is upstream response schema coupling: the mapper is strict by design, so an upstream cosmetic rename such as next_cursor to next becomes a hard failure on a page users browse. Relaying foreign tokens byte-for-byte is required for correctness, but bookmarked or shared page URLs inherit the upstream token signing, expiry and embedded claims. Also decide filter serialization up front, because a shape mismatch produces a silent no-results page rather than an exception.
- Is laravel-ddd maintained, and how does it compare to other DDD or modular packages?
- The package is pre-1.0 and currently on the 0.8.x line, with 0.8.0 adding remote aggregate persistence and 0.8.1 closing the read half of the API story with cursor pagination. It is a focused DDD toolkit, not a full modular monolith suite: it concentrates on generators, layered bounded contexts, per-domain providers and repository interfaces. Pin a version and read the changelog for each release, because 0.8.0 changed Entity::hydrate() version semantics under a Fixed heading.