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 Dev Laravel Package

aulasoftwarelibre/ddd-dev

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require aulasoftwarelibre/ddd-dev
    

    Ensure your project meets the PHP 7.2+ and ext-mbstring requirements.

  2. First Use Case

    • Event Sourcing Foundation: Leverage the Prooph Event Sourcing integration for domain events.
      use AulaSoftwareLibre\DDDDev\EventSourcing\EventStore;
      $eventStore = new EventStore(); // Configure with your storage (e.g., Doctrine, MongoDB)
      
    • Domain Model Scaffolding: Use Symfony Maker Bundle (included) to generate DDD-specific classes (e.g., Entities, Value Objects, Aggregates).
      php bin/console make:ddd:entity User
      
  3. Key Entry Points

    • src/Domain/: Organize your domain models here.
    • config/ddd.php: Check for package-specific configurations (if any; may need manual setup).

Implementation Patterns

Core Workflows

  1. Event-Driven Domain Modeling

    • Aggregate Roots: Extend AulaSoftwareLibre\DDDDev\Domain\AggregateRoot for event-sourced entities.
      class Order extends AggregateRoot
      {
          public function place(): void
          {
              $this->recordThat(new OrderPlaced($this->id, $this->customerId));
          }
      }
      
    • Event Handling: Use Prooph’s EventStore to persist and replay events.
      $eventStore->load($aggregateId)->when([
          OrderPlaced::class => fn(OrderPlaced $event) => $this->handleOrderPlaced($event),
      ]);
      
  2. Symfony Maker Integration

    • Custom Templates: Override Maker templates in templates/ddd/ to fit your DDD conventions. Example: Add #[UniqueEntity] annotations to generated entities.
    • Commands:
      # Generate a Value Object
      php bin/console make:ddd:value-object Email
      # Generate an Aggregate Root
      php bin/console make:ddd:aggregate Order
      
  3. Dependency Injection

    • Register the EventStore as a service in config/services.yaml:
      services:
          AulaSoftwareLibre\DDDDev\EventSourcing\EventStore: ~
      
    • Autowire aggregates with the store:
      public function __construct(private EventStore $eventStore) {}
      

Integration Tips

  • Doctrine ORM: Pair with prooph/event-store-doctrine for persistence.
  • Testing: Use AulaSoftwareLibre\DDDDev\Testing\TestAggregateRoot for unit tests:
    $aggregate = new TestAggregateRoot(Order::class);
    $aggregate->record(new OrderPlaced(...));
    $aggregate->assertRecordedThat(OrderPlaced::class);
    

Gotchas and Tips

Pitfalls

  1. No Official Documentation

    • The package lacks a README with usage examples. Rely on Prooph’s Event Sourcing docs for event-store patterns.
    • Workaround: Study the tests/ directory for usage patterns.
  2. Symfony Maker Bundle Quirks

    • Template Overrides: Ensure your templates/ddd/ directory is auto-discovered by Symfony Maker. Add to config/packages/maker.yaml:
      maker:
          namespace: '%kernel.project_dir%/templates'
      
    • Command Conflicts: If using other Maker bundles (e.g., symfony/maker-bundle), prioritize this package’s commands by adjusting the maker.yaml order.
  3. Event Store Configuration

    • The package assumes you’ll configure the EventStore manually. For Doctrine:
      $eventStore = new EventStore(
          new DoctrineEventStore(),
          new DoctrineEventRepository()
      );
      
    • Tip: Use environment variables for connection strings (e.g., DATABASE_URL).

Debugging

  • Event Replay Issues

    • If aggregates fail during replay, check:
      • Event class namespaces (must match recorded events).
      • Constructor arguments in events (must align with aggregate state).
    • Enable Prooph’s debug mode:
      $eventStore->setDebug(true);
      
  • Maker Command Errors

    • Clear cache after adding custom templates:
      php bin/console cache:clear
      

Extension Points

  1. Custom Value Objects

    • Extend AulaSoftwareLibre\DDDDev\Domain\ValueObject for shared logic:
      class Money extends ValueObject
      {
          public static function fromFloat(float $amount): self { ... }
      }
      
  2. Domain Events

    • Create a DomainEvent interface for consistency:
      interface DomainEvent extends \Prooph\EventSourcing\DomainEvent {}
      
  3. Testing Utilities

    • Extend TestAggregateRoot for custom assertions:
      class CustomTestAggregateRoot extends TestAggregateRoot
      {
          public function assertOrderPlaced(): void { ... }
      }
      
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle