DEV Community

Cover image for ECA vs Custom Modules in Drupal - When to Use Which
Neharika Mohan
Neharika Mohan

Posted on

ECA vs Custom Modules in Drupal - When to Use Which

If you've worked with Drupal long enough, you've faced this decision:
Do I build a custom module for this or can ECA handle it?
Here's a straight answer.

Use ECA When

  • The logic is workflow-based
    Approvals, notifications, reminders, role assignments anything that follows an "if this then that" pattern is exactly what ECA is built for.

  • Non-developers need to maintain it ECA workflows live in the admin UI. Your client or site admin can read, modify, and debug them without touching code. A custom module cannot offer that.

  • Speed matters A workflow that would take a day to build as a custom module can be done in ECA in an hour. For agencies and freelancers, that margin is money.

  • You want reusability ECA configs export as YAML. Drop them into any Drupal project and they work. No copy pasting PHP across projects.

Use a Custom Module When

  • You need complex business logic Heavy data transformations, third-party API calls with custom authentication, or multi-step calculations are better handled in PHP where you have full control.

  • Performance is critical ECA adds overhead. For high-frequency operations like processing thousands of records a lean custom service will always outperform an ECA workflow.

  • You need testability Custom modules can be unit tested. ECA workflows currently cannot. If your team writes tests, custom code wins here.

  • ECA doesn't have the event or action you need ECA is extensible but not infinite. Sometimes the specific trigger or action you need simply doesn't exist yet and writing a custom module is the only option.

The Sweet Spot Use Both
This is what experienced Drupal developers actually do.
Write a custom ECA action or event in PHP, then wire it into an ECA workflow visually. You get the power of custom code with the flexibility of a visual workflow.
Example: Write a custom action that calculates a student's eligibility score in PHP then trigger it from an ECA workflow on form submission, send an email based on the result, and assign a role. Clean separation of concerns.

Quick Reference

Situation Use
Email/notification workflows ECA
Approval & review flows ECA
Heavy data processing Custom module

Bottom Line
ECA is not a replacement for custom modules it's a replacement for simple custom modules. Know the difference and you'll ship faster, write less throwaway code, and build systems that clients can actually maintain.
In the next post I'll show you how to write a custom ECA action in PHP and plug it into a workflow.

Follow so you don't miss it.

Top comments (0)