Setting up XDebug for debugging PHP applications

August 29th, 2018

Recently I had to set up a development server to debug some performance issues for a WordPress site. The best tool I've found for such work is XDebug, an extension for PHP that adds some helpful debugging capabilities.

One important feature is the ability to create profile logs that can be parsed by tools like KCacheGrind.

Setting up the server

I usually use Vagrant to create and manage the virtual servers running on my local machine.

We'll need to create a Vagrantfile that sets up a simple CentOS 7 server. I personally use the centos-7.2 box from bento.

Vagrant.configure("2") do |config|
  config.vm.box = "bento/centos-7.4"
  config.vm.network "private_network", ip: "192.168.50.50"
end

Start the server up with vagrant up

Once it is running, ssh into the server with vagrant ssh