When:
to
Room:
Room BoF 1 (118)
Tags:
bof
Track:
SVG
bof

Leveraging the Command Pattern: Enhancing Drupal with Symfony Messenger

Leveraging the Command Pattern: Enhancing Drupal with Symfony Messenger

Luca Lusso (lussoluca)

Managing user interactions can be complicated. Some operations must be executed immediately, whereas others can be scheduled for the future. Drupal core has batches and queues, but we can do better. We can dispatch commands that can be synchronous and asynchronous, in real-time or delayed.

The Command pattern is a behavioral design pattern widely used in web applications. It allows developers to build more decoupled, resilient, and easy-to-test systems.

In the PHP landscape, the Symfony Messenger component provides a full-featured implementation of the Command pattern, and, as we all know, there’s a module for that. The Symfony Messenger (https://www.drupal.org/project/sm) module provides everything we need to start writing code following the Command pattern.

In this BOF, we’ll want to expose the current state of the Symfony Messanger module and discuss how to:

* replace the core’s queue worker system with a more efficient one
* send emails asynchronously (or delayed)
* replace the core’s hook_cron with Symfony Scheduler