This is a tutorial on how to configure debugging for any PHP web application using PHP Storm, Vagrant and X-Debug.
One of my web-development workflows involves using Vagrant with a LAMP stack on it. The vagrant configuration I use is based on this: Vagrant LAMP stack. I’ve used this method over a dozen times this year on multiple projects and I thought I’d do a short write-up for future reference. It may benefit other developers as a starting point to quickly get a development environment set up for PHP application development.
NOTE: You must have Virtual Box and Vagrant already installed on your workstation. The debugging portion of this post focuses on setting up the PHP Storm IDE, so if following this post, make sure you have that installed on your workstation.
PHP Storm Setup
Step 1: Download a release or checkout a branch.
Step 2: Open project in PHP Storm. In PHP Storm select the Add Configuration debug option at the top of the IDE. This will open another window.
Step 3: Select the Templates accordion.
Step 4: From the list select PHP Remote Debug → Filter Debug Connection by IDE Key → Server Ellipses. This will open another window for server details.
Step 5: Enter Server Details:
- Server Name
- Host:
localhost:8099
- Port: 9000
- Debugger:
Xdebug
- Select use path mappings
- Set Absolute path on the vagrant server:
/var/www/myapp
- Click Apply and OK to save settings.
Note: These server settings are declared in the Vagrant
file and the prepare/setup.sh
file
Step 6: Select → Filter debug connection by IDE key.
- Make sure vagrant server is selected
- Enter
PHPSTORM
for the IDE key from theprepare/setup.sh
file
Select Create Configuration. This uses the Template to create a new Remote Debug configuration
This concludes setting up xDebug with PHP Storm.
Start Debugging
….start