Posted on July 29, 2019
Last week at Laracon US I gave a talk titled Eloquent Performance Patterns. In that talk I used a custom Laravel Debugbar metric I created to track how many Eloquent models were being hydrated throughout a request. I've had a lot of people asking about this, so today I submitted a pull request to the Laravel Debugbar to add this as an official metric.
Here's a quick video illustrating how this metric works, and how to use it in your projects.
To install the Laravel Debugbar in your app, add it via Composer:
composer require barryvdh/laravel-debugbar --dev
Next, publish the config:
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
Finally, enable the
'collectors' => [ // ... 'logs' => false, // Add the latest log messages 'files' => false, // Show the included files 'config' => false, // Display config settings 'cache' => false, // Display cache events 'models' => true, // Display models ],
If you are interested in learning more about creating dynamic relationships in Laravel, be sure to see that article here.
🔥 Also, at Laracon I announced that I'm working on a brand new premium video course called Eloquent Performance Patterns. My goal with this course is to teach Laravel developers how to drastically improve the performance of their applications by pushing more work to the database, all while still using the Eloquent ORM. If that sounds interesting to you, be sure to leave your email address (on the course website) so I can notify you when the course is ready!