Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ddd Core Laravel Package

becklyn/ddd-core

DDD/CQRS/event-sourcing core building blocks for PHP: entity identities, domain events, command handling, transactions, and an event store workflow. Framework-agnostic abstractions with Symfony/Doctrine/SimpleBus bridge packages available.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Architectural Alignment with DDD Principles:

    • Enable ubiquitous language and bounded contexts for teams working on complex domains (e.g., e-commerce, healthcare, or fintech). This package enforces aggregate roots, domain events, and event sourcing, reducing ambiguity in business logic implementation.
    • Example: "Our current order system treats discounts as a percentage field in the database. With becklyn/ddd-core, we can model discounts as a separate aggregate with its own invariants (e.g., max discount per customer), making the logic clearer for both developers and business stakeholders."
  • Event-Driven Microservices Strategy:

    • Accelerate decomposition of monolithic applications by providing a standardized way to model domain boundaries and communicate via events. The package’s event bus and command correlation simplify cross-service interactions.
    • Example: "We’re planning to split our monolith into ‘Inventory’, ‘Orders’, and ‘Payments’ services. This package’s event sourcing ensures we can replay events when services are temporarily unavailable, avoiding data loss during migration."
  • Compliance and Auditability:

    • Address regulatory requirements (e.g., GDPR, SOX, HIPAA) by leveraging immutable event logs for full audit trails. The event store allows reconstruction of any past state, which is critical for dispute resolution or forensic analysis.
    • Example: "Our payment processing system must retain a complete history of all transactions for 7 years. Event sourcing lets us store only events (not snapshots), reducing storage costs while meeting compliance needs."
  • Performance Optimization via CQRS:

    • Improve read performance for analytics or reporting by separating write-heavy commands from read-optimized queries. The package’s projection support enables materialized views for fast reads.
    • Example: "Our user dashboard queries are slow because they join 10 tables. With CQRS, we can pre-compute aggregates (e.g., ‘total orders per user’) and update them via event subscribers, reducing query complexity."
  • Saga Orchestration for Complex Workflows:

    • Simplify multi-step transactions (e.g., order fulfillment, loan approvals) with built-in command correlation and compensating actions. The package’s transaction rollback ensures atomicity even across distributed systems.
    • Example: "Our current order fulfillment process fails if inventory checks pass but shipping labels can’t be generated. This package’s saga pattern lets us automatically release reserved stock if any step fails, without manual error handling."
  • Tech Stack Standardization:

    • Reduce vendor lock-in by providing framework-agnostic abstractions (interfaces for entities, events, and commands). The Symfony/Laravel bridges allow gradual adoption while keeping the core logic portable.
    • Example: "We’re using Laravel for our API but may switch to Symfony for our backend. This package’s abstract base classes let us keep our domain logic consistent across frameworks."
  • Reducing Technical Debt in Legacy Systems:

    • Refactor anemic domain models into rich aggregates with explicit invariants. The package’s domain event validation prevents invalid state transitions early.
    • Example: "Our current ‘User’ model is just a table with getters/setters. With this package, we can model user roles as an aggregate, ensuring only valid transitions (e.g., ‘premium’ → ‘admin’) are allowed."

When to Consider This Package

  • Adopt if:

    • Your domain requires strict business rules that are hard to enforce in traditional MVC (e.g., financial calculations, legal workflows).
    • You need eventual consistency for distributed systems (e.g., microservices, serverless architectures).
    • Your audit/compliance needs demand immutable logs (e.g., healthcare, fintech, government).
    • You’re building a greenfield system or refactoring a monolith with clear domain boundaries.
    • Your tech stack is PHP/Laravel/Symfony, and you want to avoid reinventing DDD/CQRS from scratch.
    • You need native saga support for long-running transactions (e.g., multi-step approvals, cross-service workflows).
    • Your scaling challenges involve decoupling reads/writes (e.g., high-traffic APIs with complex reporting).
    • Your team has moderate PHP/DDD experience (or is willing to invest in training).
  • Look elsewhere if:

    • Your domain is simple CRUD (e.g., blogs, basic CMS). Use Eloquent or repository pattern instead.
    • You lack PHP expertise or DDD experience. The package assumes familiarity with aggregates, entities, and event-driven architecture.
    • Your performance needs are read-heavy but simple (e.g., static content). A cache-first approach may suffice.
    • You’re locked into a non-PHP stack (e.g., Node.js, Java, Go). Consider domain-specific frameworks in those ecosystems.
    • Your team resists architectural changes. DDD/CQRS requires cultural buy-in and discipline in modeling.
    • You need real-time consistency (e.g., chat apps, collaborative editing). Eventual consistency may introduce latency issues.
    • Your event volume is extremely high (e.g., IoT telemetry). Consider specialized event stores (e.g., Kafka, Pulsar).

How to Pitch It (Stakeholders)

For Executives (Business/Finance)

"This package helps us build software that matches how our business actually works—not how databases or frameworks force us to structure it. For example:

  • Fewer bugs: By modeling orders, payments, and inventory as separate aggregates, we can enforce rules like ‘no refunds after 30 days’ at the domain level, not just in validation code.
  • Regulatory confidence: Event sourcing gives us immutable audit logs, so we can prove every transaction to auditors without manual reconciliation.
  • Future-proof architecture: If we need to split our monolith into microservices later, this package’s event-driven design makes it easier to extract domains cleanly without rewriting everything.
  • Cost savings: Instead of spending 6 months building a custom event-sourcing layer, we get 80% of the functionality out of the box, with room to customize the rest.

This isn’t just ‘better code’—it’s reducing risk, cutting compliance costs, and enabling faster innovation."


For Engineering Leaders (CTO/Tech Leads)

"This package gives us opinionated, production-ready DDD/CQRS scaffolding in PHP, solving key pain points:

  • Aggregate boundaries: Enforces ubiquitous language and clear domain ownership (e.g., ‘Order’ aggregate owns ‘Discounts’, not the ‘User’ aggregate).
  • Event sourcing: No more ‘lost updates’—every state change is an immutable event, so we can replay history for debugging or compliance.
  • CQRS: Decouples reads from writes, so our analytics queries won’t slow down transactional APIs.
  • Saga support: Automatic compensating actions for failed workflows (e.g., roll back inventory if payment fails).
  • Framework flexibility: Works with Symfony/Laravel out of the box, but the abstract interfaces let us swap implementations (e.g., use Doctrine for persistence or Redis for event storage).

Tradeoffs:

  • Learning curve: Requires DDD discipline (e.g., modeling aggregates correctly).
  • Initial complexity: More moving parts than Eloquent, but long-term maintainability improves.
  • Not for simple CRUD: If your app is just users + posts, this is overkill.

Recommendation: Pilot on a high-risk domain (e.g., payments, inventory) where correctness and auditability matter most."*


For Developers (Backend Team)

"This package saves us from reinventing DDD/CQRS wheels while giving us structure to avoid anemic domain models. Here’s how it helps:

  • Entities & Aggregates: No more god objects—model ‘Order’ as an aggregate root, with ‘Payment’ and ‘Shipping’ as child entities, all with explicit invariants.
  • Domain Events: Every state change is an event (e.g., OrderCreated, PaymentFailed), so we can react to changes without polling.
  • Event Sourcing: Reconstruct any past state by replaying events—no more ‘oops, we deleted a record’ in audits.
  • Command Bus: One command → one handler, so no more spaghetti middleware for business logic.
  • Testing: Built-in BDD-style test helpers (e.g., CommandHandlerTestTrait) make it easier to **test
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cadot.eu/make
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky