Skip to content

Xdebug Profiling

Although DDEV has more sophisticated profiling capabilities with xhprof and Blackfire, it also has built-in support for Xdebug profiling.

Basic usage

  • Create the directory .ddev/xdebug, which is where the output files will be dumped.
  • Switch Xdebug to profiling mode by adding this in .ddev/php/xdebug.ini:

    xdebug.mode=profile
    xdebug.start_with_request=yes
    xdebug.output_dir=/var/www/html/.ddev/xdebug
    xdebug.profiler_output_name=trace.%c%p%r%u.out
    
  • Enable Xdebug with ddev xdebug on.

  • Make an HTTP request to the DDEV project and the profile will be located in .ddev/xdebug directory.
  • Analyze it with any call graph viewer, for example kcachegrind.
  • When you’re done, execute ddev xdebug off to avoid generating unneeded profile files.
  • You can also toggle Xdebug on and off using ddev xdebug toggle.