Search code examples
phplaravelperformanceoptimization

How to get detailed Performance Tracking in Laravel?


In Laravel, the general way to debug performance is to use Laravel Debugbar

What that doesn't include is things like:

  • View Composers (say you include a frontend.* composer and it shares a variable to 2000 views, there's no way to know that's affecting your)
  • Queries that are run from in a model presenter rather than a controller.
  • Basically anything that's not called from the controller.
  • Debugging if an included partial is the speed culprit.

With all of this, it's difficult to debug where the performance is being slowed down.

Does anyone have any tools or details on how to debug FULLY end to end and each little area? Visual tools preferred. Haven't looked as much into Xdebug, but I see tools like Datadog/Newrelic but haven't played with those much either. Would be great to be able to debug it locally rather than in production environment.

I want to be able to see that from all my middleware, view composers, included partials that there's one particular function that's causing 200ms due to a query or inefficient piece of code and I haven't found anything that can do that easily without adding breakpoints or start/stop timers everywhere but the app is too big for that.

Any help appreciated!


Solution

  • I have found that Blackfire is doing the trick. Seems to be relatively easy to install and can run it free locally.

    As of 2024, Blackfire is is no longer free, even for local install. Seems to be ~$35/mo USD for a development plan.