I have set up my local development machine (Mac Mini(late 2014) , El Capitan 10.11.6) for WordPress PHP development and debugging, specifically for WordPress Plugin Development. I prefer to to use Eclipse PDT and Xdebug for debugging.
We also use our quick start guide to install WordPress for local development on your development machines.
The only issue I had really was configuring Eclipse PDT for debugging using Xdebug. This was due to little gotcha’s , I ran into initially that I lost a bit of time on so I thought I would document this with the hope of saving somebody else time. (Always believe in paying forward 🙂 )
Our approach to WordPress development has evolved. We now make use of Docker for development environments. You may want to read our posts Using Docker for WordPress Development & Docker and WordPress debug environment[/su_note]
Install Xdebug via HomeBrew
In my particular instance we are developing and testing for WordPress using PHP 7.0 , if you looking for a particular PHP version of xdebug simply swap out the version numbers
Due to the fact that a few of PHP frameworks, in our case CakePHP and Laravel, all need xdebug to be deactivated for when they do generation, it install a handy little CLI program to toggle Xdebug on and off.
This enable to simply switch xdebug on or off from the terminal :
Edit Xdebug Config
We need to make a few edits to the xdebug configuration, if you’re using POMAMA, you can get the information as regards it’s location from PHPInfo,
We’ll use nano to edit this file, these are the settings that worked for me. You may want to edit them for your environment
We now need to restart our apache webserver for the changes to take effect. Ensure you have toggled xdebug to on before you restart.
Open your eclipse PDT and open your WordPress Project . We make use of Eclipse Neon internally so the screens may look a little different depending on your version of Eclipse. I am assuming you have created a new PHP Project and imported your WordPress installation.
Configure a new PHP Web Application debug configuration
Configure the debugger to be xDebug and configure it to use the same port as you set as the remote_host in xdebug.ini
Uncheck the Break at First Line checkbox, as you don’t really want to step through 1000’s of lines of code to get to your issue 🙂
Enter your base URL for your wordpress installation.
In our case we make use of dnsmasq to create local dns names so our base url is usually http://wordpress.dev. If you followed our links earlier your setup should be similar.
You can now click finish.
You should now be able to place a break point at any area of the code your interested in, hit the debug and open the Debug Perspective.
If you run into issues with a “Waiting for Debug” play around with the port numbers, but usually 3001 works well for us.
A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Latest posts by Gary Woodfine (see all)
- Why every business needs a web maintenance retainer - March 11, 2019
- Connect AWS Lightsail SSH with ubuntu terminal - March 1, 2019
- Set up Anaconda, Jupyter Notebook, Tensorflow for Deep Learning - February 20, 2019