- Assuming that you have already installed php and apache
- Install xDebug php extension
# Ubuntu 16.04, php 7.0
sudo apt-get install php-xdebug
# Ubuntu 14.04, php 5.6
sudo apt-get install php5-xdebug
# Mac OS with Homebrew
# brew install php<version>-xdebug
# Example for php v7.2
brew install php72-xdebug
- Edit your
xdebug.ini
- Your
xdebug.ini
paths should look like this- Ubuntu
/etc/php/7.1/mods-available/xdebug.ini
- macOS
/usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
- Ubuntu
- You can run
locate *xdebug.ini
to findxdebug.ini
file location - Add these lines without modifying exiting lines
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
xdebug.show_error_trace = 1
xdebug.remote_autostart = 0
xdebug.file_link_format = phpstorm://open?%f:%l
- Above configs are bare minimum, read all options here
- Restart the apache server to reflect changes
# Ubuntu
sudo service apache2 restart
# MacOS
sudo apachectl restart
-
Configure phpStorm
-
Go through - Settings >> Languages & Frameworks >> PHP >> Debug
-
Check that 'Debug port' is the same you have in your
xdebug.ini
. In our case it was9000
. -
Save and close the Settings Dialog
-
Start debugging
-
Create some breakpoints in your project
-
Make sure those breakpoints gets executed when your visit your virtual host in browser.
-
Start listener by clicking on the telephone 📞 button on top toolbar
-
If you can't find telephone button; then go through menus - Run -> Start listening for PHP Debug Connections
-
In your browser access your project url like this
http://localdomain.test/?XDEBUG_SESSION_START=1
-
OR use bookmarks
-
OR use this chrome extension
-
You should see a popup window in PhpStorm , click Accept connection
-
Done, enjoy debugging !!!
sudo phpdismod xdebug
sudo phpenmod xdebug
sudo phpdismod -s cli xdebug
- Try to change the port to something else, for example
18000
- Enable
Break at first line
in phpStorm php debug settings - Set
xdebug.remote_autostart
to1
if you don't want to bother with browser extensions