@
@
@Twitt2017-10-09 20:59:04
Doctrine ORM
@Twitt, 2017-10-09 20:59:04

Entity and Repository - difference?

I started to dig into the project, I saw that there is work with the doctrine, Repository, Entity.
As I understand it, requests are mostly made in repositories, and entity simply describes the structure of the table? (I saw there columns like
private $id; ... and with some kind of annotations.
In general, in simple, human language, why do we need repositories and entities?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Kolzhanov, 2021-04-15
@o-kolzhanov-leko-team

In simple terms (in fact, a little more complicated):
Entity is an entity, displaying one record in the database.
Reepository is a class for working with a table in a database, as an example, CRUD operations.
This separation allows you to implement the principle of single responsibility and makes the code a little better (compared to ActiveRecord, for example).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question