Skip to content

Instantly share code, notes, and snippets.

@Arbagen
Created May 23, 2017 09:34
Show Gist options
  • Save Arbagen/b42cc87f86f33286fd22bd761b668f7a to your computer and use it in GitHub Desktop.
Save Arbagen/b42cc87f86f33286fd22bd761b668f7a to your computer and use it in GitHub Desktop.
install xdebug

🪲 Install and Configure xDebug on Ubuntu and Php Storm 🐘

  • 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
  • Now edit your php.ini (for me it was /etc/php/7.0/apache2/php.ini) and add these lines at last
[Xdebug]
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
  • Above config is bare minimum, read all options here
  • Make sure xdebug.so path is correct in above configuration
  • To find the xdebug.so file path; run this command
locate xdebug.so
  • Above command will return the correct path to xdebug.so file

  • Now check php version

php --version
  • Above command should return like this
PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
  • Notice the Xdebug version in last line
  • Restart apache server to reflect changes
sudo service apache2 restart
  • Configure phpStorm

  • Go through - Settings >> Languages & Frameworks >> PHP

  • Lets set php Interpreter, to do so; click on three dots [...] button

  • On the new window click on plus [+] button and select /usr/bin/php from suggestion popup

  • Save and close this window

  • Now, on the Settings window select the Interpreter you just created then save and close

  • Start debuging

  • In phpStorm create some breakpoints in your project

  • Start listener by clicking on the telephone 📞 button on top toolbar

  • In your browser access your project like this, OR use bookmarks

http://localdomain.dev/?XDEBUG_SESSION_START=1
  • You should see a popup window in phpStorm , click Accept connection
  • Done !!!

Disable xdebug temporary

sudo phpdismod xdebug

Enable xdebug back

sudo phpenmod xdebug

Sublime Text 3 user ?

Ubuntu 16.04, php 7.*, phpStorm 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment