The Anti-Corruption Layer: How to Protect Your Domain from External APIs
There comes a point in almost every project when someone says, "We need to connect to API X." Everyone nods. It sounds simple enough. A few hours later, that API's response model has started appearing in controllers, business services, and tests. Before we know it, we've allowed an infrastructure decision to contaminate the core of our application.
This article is about how to prevent that. About a pattern called the Anti-Corruption Layer (ACL): where it comes from, why it matters, and how to apply it in practice with Symfony using IntegrationEngine — a bundle designed from the ground up to make this pattern not optional, but the only way to work.
The Problem: The Outside World Leaks In
Imagine we're integrating with Stripe to manage payments. The endpoint GET /v1/charges/{id} returns something like this:







