Xdebug Profiler Files Not In xdebug.profiler_output_dir

Published: January 17, 2019

Tags:

Something that’s tripped up both myself and devs that I’ve worked with is not finding Xdebug profiler files in the expected directory (/tmp by default).

It usually goes something like this…

  • Enable the Xdebug profiler by adding xdebug.profiler_enable_trigger = 1 to a .ini file.
  • Make a request with ?XDEBUG_PROFILE =1 in the GET string.
  • Check for the output file in /tmp
  • Pull out hair because it’s not there.

This may be accompanied by running a sanity check, only to be accompanied by more hair pulling…

$ php -r 'var_dump(ini_get("xdebug.profiler_output_dir"));'
string(4) "/tmp"

If you find yourself in this situation, the likely cause is that your system is using PrivateTmp.

In this case the cachegrind file will actually be placed in a folder like this:

/tmp/systemd-private-ff40cf656c534501b9735e4b53c9bcd3-php-fpm.service-4C70G0/tmp/

The best way to find the file in this case is as follows:

sudo find /tmp/ -name '*cachegrind*'

Max Chadwick Hi, I'm Max!

I'm a software developer who mainly works in PHP, but loves dabbling in other languages like Go and Ruby. Technical topics that interest me are monitoring, security and performance. I'm also a stickler for good documentation and clear technical writing.

During the day I lead a team of developers and solve challenging technical problems at Rightpoint where I mainly work with the Magento platform. I've also spoken at a number of events.

In my spare time I blog about tech, work on open source and participate in bug bounty programs.

If you'd like to get in contact, you can find me on Twitter and LinkedIn.