- Assuming that you have already installed php and apache
- Install xDebug php extension
# Arch Linux , Manjaro
sudo pacman -Sy xdebug
# Ubuntu 16.04,18.04
sudo apt-get install php-xdebug
- Edit your
xdebug.ini - Your
xdebug.inifile path (according to your php version) should look like this/etc/php/7.1/mods-available/xdebug.ini
- Add these lines without modifying exiting
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_port = 9000
xdebug.idekey = PHPSTORM
xdebug.show_error_trace = 1
xdebug.file_link_format = phpstorm://open?%f:%l
xdebug.max_nesting_level=1000
- Restart the apache server to reflect changes
sudo service apache2 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 website 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 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