Symfony

Doctrine Advanced

Migrations, lifecycle callbacks, events, inheritance, custom types, performance optimization

24 питань зі співбесід·
Mid-Level
1

Which command generates a new Doctrine migration in Symfony?

Відповідь

The doctrine:migrations:diff command compares the current database schema with entity metadata and automatically generates a migration containing the differences. This is the recommended method for creating migrations as it avoids manual errors and ensures consistency between code and database.

2

Which lifecycle callback is triggered before an entity is inserted into the database?

Відповідь

The PrePersist callback is executed before a new entity is persisted to the database. This is the ideal place to initialize default values like creation timestamps or generate unique identifiers before insertion.

3

How to enable lifecycle callbacks on a Doctrine entity?

Відповідь

The HasLifecycleCallbacks attribute must be added to the entity class to enable callbacks. Without this attribute, methods annotated with PrePersist, PostUpdate and other callbacks will never be executed by Doctrine.

4

Which command executes all pending migrations in Doctrine?

5

Which Doctrine callback to use for automatically updating an 'updatedAt' field on each modification?

+21 питань зі співбесід

Опануй Symfony для наступної співбесіди

Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.

Почни безкоштовно