Symfony

Symfony Architecture

Hexagonal architecture, DDD, CQRS, repositories, DTOs, value objects, bounded contexts

24 interview questionsยท
Senior
1

In hexagonal architecture, what is the main role of ports?

Answer

Ports are interfaces that define contracts between the business domain and the outside world. Primary ports (or driving ports) allow external actors to trigger actions in the domain, while secondary ports (or driven ports) allow the domain to interact with external infrastructure like databases or third-party services. This abstraction allows changing implementation without affecting the business domain.

2

What is an adapter in Symfony hexagonal architecture?

Answer

An adapter is a concrete implementation of a port that bridges the outside world and the domain. For example, a DoctrineUserRepository is an adapter implementing the UserRepositoryInterface port. On the primary side, a Symfony controller is an adapter that adapts HTTP requests to domain use cases. This separation allows testing the domain independently from infrastructure.

3

In Domain-Driven Design, what is the main characteristic of a Value Object?

Answer

A Value Object is defined by its attributes, not by an identity. Two Value Objects with the same values are considered equal. They are immutable: any modification creates a new instance. For example, an Email or Money object are typical Value Objects. This immutability ensures data consistency and makes reasoning about code easier in complex systems.

4

What is the role of an Aggregate Root in DDD?

5

What is a DTO (Data Transfer Object) and when to use it in Symfony?

+21 interview questions

Master Symfony for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free