Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tnort's avatar
Level 4

Eager loading vs lazy loading

hi all,

just a best practice question.

I work on a CRM where basically I have an application that has to go through multiple stages (6) at the moment. At each stage, a new relationship is updated/created (choose a course, upload documents, etc.). Would it be better to lazy load and refer to the relationships e.g. $application->student->first_name or better would be to eager load the whole application (using the with('student', 'documents')) and refer to the fields as $application['student']['first_name']?

I get the differences but I cannot understand how to use it right and what is the best practice.

Any reply is appreciated, thank you.

0 likes
2 replies
tnort's avatar
Level 4

@Randy_Johnson thank you for your reply, I've read this sort of article but I am still confused about where and what should I use to optimise the requests as much as possible.

Please or to participate in this conversation.