Debugging PhpStorm with xDebug on Ubuntu – Solving Common Set-up Problems

Do you love programming in PHP?  If you don’t, could it be your editor/IDE?

As a programmer, the tools you use, and how well you use them, can have a huge impact on your productivity.

How much time have you wasted writing var_dump statements and printing log messages?

What if you could just inspect the contents of a variable whenever you wanted?

That’s what debugging allows you to do, and that’s what I do every day.

Not sure what the array keys are?  Inspect the variable.  Not sure of the object’s properties?  Inspect the variable.  Not sure if a function is running?  Stick a breakpoint on its first line, and see if your program stops execution at that point.

Debugging saves time… But setting up debugging can also take some time, as it requires the installation of xdebug and the correct configuration set-up.  Plus, if you’re using a virtual machine like a vagrant box, you’ll need to set up path mappings.

PhpStorm Has Built-in Debugging for xdebug

See that screenshot?  If you’re trying to get xdebug to work with phpstorm, and you’ve already installed xdebug, then you should go to: Run –> Web Server Debug Validation (For PhpStorm version 2016.3.2, it’s the last option in that Run dropdown menu.)

When that validation box first opens, you’ll probably see an error message.  Click on “validate” and it might work right out of the box. If not, check that the path is set to a location that the web server can serve up. If you already have a project, this can just be the directory to the project.  (By default, Apache only serves up files from within a specific directory, and as programmers we usually put our web apps inside that directory, because then we can view them with a web browser.)

Settings for Ubuntu 16.04 with Apache and PHP 7

If you’re running Ubuntu with Apache and PHP locally, make sure that “Local Web Server or Shared Folder” is selected, and enter the following:

Path to create validation script: /var/www/html/

URL to validation script:

Click Validate….. and PhpStorm will tell you what’s wrong!!

In this case, it was easy.  I just had to add xdebug.remote_enable=1 to my php.ini file

And then I just had to restart Apache:

systemctl restart apache2

Hope that was helpful!


Goodbye Windows, Hello Ubuntu

Quite some time ago, I installed Ubuntu on my computer alongside my Windows 7 installation.  I had an extra solid state hard drive (they’re cheap these days) and followed the instructions for setting up dual-boot.  I played with Ubuntu a bit, was disappointed that I couldn’t do some things on it, and soon resumed booting into Windows.

More recently, I started using a MacBook Pro for work, and as you may know, it has a bash kernel, and so the commands are similar to the ones you’d write on any linux based machine.  I also started using Ubuntu on a vagrant box (virtual machine).  So linux began popping up all throughout my programming work.  I still had a Windows computer, and often returned to it after work, but I always found myself getting annoyed at it.  And also typing ls instead of dir

Little annoyances pile up.  The last straw was that Windows updates began to fail and Windows started filling up my hard drive with temp files.

Windows became no longer worth it to me.  So I booted into Ubuntu, upgraded to Ubuntu 16.04 LTS, and got everything working… well, almost everything… I’ve still got some things that appear to be incompatible with Ubuntu out-of-the-box, but I thought I’d share here my successes:

Audiophile Sound Equipment Works — Yay!

One of the things I like to do on my computer is listen to music.   It is surprising the number of times that I’ve made a software or hardware upgrade only to have my sound equipment not work.  So often, something I change introduces faint beeping noise, static noise, electrical interference sounds, buffering issues, etc… So many things can go wrong and all I want to do is listen to lossless music files with 20 tabs of chrome open!

I’ve used various sound cards in the past, but my current set up is USB out of the computer and into my Teac UDH01 DAC.  I did some googling but was unable to find out for certain whether this was compatible with Ubuntu, since on Windows it requires specific drivers.  (The Teac also had optical and coaxial inputs, which are good alternatives if you have any issues with the USB driver, but not all motherboards have those outputs.)

It did take me a couple of hours to figure out how to get the computer to output 192 kHz.  The Teac UDH01 displays the sampling rate on the front of it.  There is a huge difference in how a 48 kHz sampling rate sounds versus 192 kHz.  At the lower rate, lots of data is omitted, and this makes the music sound flat because you’re missing the small sounds that help give you room acoustics.

How to get the Teac UDH01 to work with Ubuntu 16.04

  1. Hook it up.
  2. Install Audacious Media Player.  You can do this at the command line with:
    apt-get install audacious
  3. Open up Audacious and go to File –> Settings –> Audio and set the output plugin to PluseAudio Output and set the bit depth to 32. (See below screenshot.)
  4. Edit the configuration file for pulseaudio server according to these instructions.  Basically, you’ll want to edit the file at /etc/pulse/daemon.conf by uncommenting and changing the default-sample-format and default-sample-rate.
  5. Restart pulseaudio with pulseaudio -k (or just restart your computer)

Audacious Settings on Ubuntu for Teac UD-H01

Got my Touchpad Working (Sort of)

Ubuntu is definitely getting better at supporting more things out of the box.  I have a Logitech T650 Touchpad and it does work out of the box with Ubuntu, although it’s a little glitchy, unfortunately.   I find that I sometimes accidentally initiate “drag and drop” or right click when I’m trying to scroll.  I’m not sure what’s the cause of this bugginess… Hopefully some smart programmer will figure that out!

I’ve found that efficient use of computers involves a lot of muscle memory, so I try to have both of my computers set up as similarly as possible.  Having to switch between the command key and the ctrl key is super annoying.  One thing I have been able to set up exactly the same on all of my computers is the direction that you move your fingers for scrolling down a page.  If you don’t like the direction, check out the settings.  I was able to get all of my touchpads to scroll in the same direction by turning off “natural scrolling.”

Got My PHP Programming Environment Set up!

One of the geeky things I do on Ubuntu is run my own personal server for developing web apps.  It was relatively simple to install Apache, Php 7, & MySQL.  Also, installing PhpStorm, my favorite IDE, was a breeze, but getting the debugging to work correctly was a little challenging.  If you run into problems, check out my blog post about how to debug xdebug configuration with PhpStorm.

On Windows 7, I was using WAMP and then later XAMP to run the alternative to the LAMP stack.  It worked, but running it all on Ubuntu works way better.  On Windows, it took a long time after starting Apache before it actually worked — some stupid bugginess.  On Ubuntu, it just all works, instantly.  And this is all on the same hardware. So my initial impression is that Ubuntu is faster than Windows, and not only for this kind of devy stuff.  Switching between music albums on Ubuntu is also near instantaneous.  While Windows is busy doing what Windows wants to do, Ubuntu is busy doing what I want it to.  And that’s why I’m happy to say good-bye to Windows…

Got my Brother HL-5340D Laser Black & White Printer Working with Ubuntu

You most likely don’t care, because my Brother printer is probably an older model than yours, but I just wanted to give props to the developers at Brother for writing a script and precise installation instructions that literally got my printer working on Ubuntu in under 5 minutes!  It even printed a neat test page at the end of the set up.  Woohoo!  I’ll continue to recommend Brother… The toner is cheaper than most competitors too (& Costco sells it).


I’m not actually anti-Windows.  I recommend Windows to my parents, since it’s more affordable than Mac, and widely compatible with all kinds of software.  I also can’t understand why Mac would introduce a touch bar instead of a touch screen for their MacBook Pros, because touching the screen is becoming the norm.  It’s the natural choice for human-computer interaction.  I’d even say that it’s a better choice than voice in most cases, but that’s something I’m interested in seeing what the future brings.  Interesting times we live in…