DEV Community

Discussion on: Domain Driven Design with PHP and Symfony

Collapse
 
ludofleury profile image
Ludovic Fleury

Hi, welcome to backend dev ! I'll hope you will have a rich journey there :)

What you are mentioning is actually a pattern: notification.
Martin Fowler wrote about it there: martinfowler.com/articles/replaceT...

When dealing with a sync command (no rabbitmq etc) I favor intercepting exception directly in the controller, I don't have access to code right now, but something like this, should work:



class MyController
{
  public function xxx() 
  {
    try {
      $this->bus->dispatch($command);
    } catch ( exception )
      // rethrow with appropriate HTTP error code
   }
  }
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
juanma1331 profile image
juanma1331

Thanks for your help. ;)