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

JarekTkaczyk's avatar

Eloquent Book coming

hello folks!

I finally started this one and will be happy to get your feedback and expectations!

https://leanpub.com/eloquence-emerging

Release in 6-8 weeks and it will cover pretty much everything you need to know about Eloquent - from the very basics like conventions and good practices through advanced stuff with the core features, to finally get to the extending the ORM to make all the hard work for you even easier!

0 likes
37 replies
pmall's avatar

@JarekTkaczyk great :)

You know I gave up answering Eloquent questions on this forum because of you.

4 likes
xingfucoder's avatar

Yesssssssssss!!! OMG!!

$eloquent->hasMany('Tricks')
        ->youDidnKnowAbout('!');

Great cover sentence :).

Thanks in advanced @JarekTkaczyk .

2 likes
frezno's avatar

You know I gave up answering Eloquent questions on this forum because of you.

me too @pmall - but simply because i usually don't know the answer ;)

good news @JarekTkaczyk - really looking forward to it

suggestions really appreciated!

i think especially for the more complicated/complex queries its really necessary to get an heads up. Multiple joins, subqueries etc pp

1 like
pmall's avatar

@JarekTkaczyk I think you should emphasize on the db structure. I see many people trying to do crazy queries and tricks, whereas they should modify their DB structure so it fits better the eloquent way of doing things. From my experience, slightly modifying db structure can dramatically reduce the amount of code and tricks needed. Some think too much in terms of db queries whereas they should think in terms of eloquent relationships.

6 likes
xingfucoder's avatar

Great @JarekTkaczyk,

I think the same of other users here. Your help about Eloquent in this forum is awesome.

Only I can say

THANKS!!

Respect to something to see in that book, with the respect of another requests:

  1. As I commented here, internal or core of Eloquent to understand how use it in an advanced way, and for extending it (with the help of the Eloquent Advanced series, some features I learned in a better way but I'd like to get more knowledge and a print reference will be great).
  2. Using Eloquent with the Repository Pattern for some advanced custom methods with the QueryBuilder capabilities and eager relations. I think when you are working with Aggregates as Repositories, you should access to the sub-entities using the Aggregate Roots, in this case the Root Model of the Entities, and another models will be accessed only through those roots. For integrity purposes that will be a more secure way to proceed. ie. Post > Comments or User > Profile. The comment and profile may doesn't exist without the root entities Post or User.
  3. Some tips to simulate some kind of Data Mapper to avoid coupling the Model to the Business Logic.
  4. Multiple View > Model binding or hierarchical models binding.
  5. How work with Transactions and, Pessimistic or Optimistic Locking.

These are some of the items that I've been looking for. Any of those wil be great.

I think other users with more specific knowledge could give you more requests.

bestmomo's avatar

As said @codeatbusiness I think that a good comprehension of Eloquent core is an essential foundation for a proper use. All our errors come because we misunderstand how it works.

@pmall a good DB structure comprehension should be a prior before to use Eloquent and is already well documented on web and in books.

2 likes
bashy's avatar

Real world examples would be good. Best way to go about for structure (as said above) and things to do wrong. :)

1 like
xingfucoder's avatar

Some real use cases that some users commented here are:

  1. CRM users, clients, contacts.
  2. CMS users, pages back-end management.
  3. Role Permissions applications. ...

Hope some of those examples help you.

1 like
toniperic's avatar

@JarekTkaczyk real world examples, please! I'd love to see an in-depth guide on relationships and the real-life example usage cases. Also some database design "standards" would be sweet.

I'd totally buy that.

4 likes
Snapey's avatar

Real world examples;

  • Scopes and creating multi-tenant applications
  • Models that relate back to themselves, eg father can have many sons, all are people
  • using Model events
1 like
zoransa's avatar

@JarekTkaczyk I have signed up do it well I will pay $42 it's answer to the life, universe and everything.

1 like
DMA's avatar

One item of particular interest is how to do complex reporting. I realise that as Eloquent is an ORM it's not really built with that in mind, but let's face it; in our daily lives as developers we often need to build applications that our clients need, irrespective of the limitations of the tools we may use.

The best real world example I can think of that would apply to many people, is an e-commerce dashboard or a CRM type of account summary. For my own individual needs, it'd be great if you could cover how best to handle reporting for large data sets (i.e. getting aggregate values for ALL clients of a certain type across the entire system, because lets face it, it'd be trivial to perform such tasks for just one user).

JarekTkaczyk's avatar

@DMA Thanks for your input. To be honest this is something I would not do with Eloquent, because most likely it doesn't add any value there. Reporting often requires so customized solutions, that there's no easy way to even show the example path, because every case might be so much different.

However I will think about it and maybe something useful will come up!

mikebarwick's avatar

Awesome. Looking forward to purchasing. Release the hounds...

keyur's avatar

Filtering fields for administrative forms like grids and records

Good luck!

keyur's avatar

Filtering fields for administrative forms like grids and records

Good luck!

JarekTkaczyk's avatar

@keyur Thanks for suggstion, but can you elaborate? I'm not sure what you mean. A use case maybe?

Next

Please or to participate in this conversation.