Skip to content

Instantly share code, notes, and snippets.

@debraj-manna
Last active November 7, 2015 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debraj-manna/7e72e784a167cad750bb to your computer and use it in GitHub Desktop.
Save debraj-manna/7e72e784a167cad750bb to your computer and use it in GitHub Desktop.
Setting up Xdebug with PhpStorm 6 on Ubuntu 12.04 LTS

Setting Up Xdebug with PhpStorm 6 on Ubuntu 12.04 LTS

Pre-requisites

  1. Php >= 5.4 is already installed.
  2. Java 7 or greater is installed.
  3. PhpStorm 6 is installed
  4. Download PhpStorm 6.0.3 from here
  5. Uzip the downloaded file.
  6. Navigate to bin directory and execute ./phpstorm.sh. (Give execute permission to phpstorm.sh if it is not already there)

Installing xdebug

  1. Execute php -i > php_info.txt on terminal
  2. Visit xdebug custom installation page & paste the content of php_info.txt (created in the above step) in the text box provided & follow the instructions.
  3. Don’t do the last step as mentioned in the xdebug installation (Adding zend_extension in php.ini). Instead follow the steps below:-
  4. Go to /etc/php5/cli/conf.d
  5. Locate 20-xdebug.ini or any file containing the name xdebug.ini. If no file exists create a file named xdebug.ini & place the below contents:-
zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.remote_autostart=1
xdebug.ide_key =  "PHPSTORM"

NOTE - zend_extension in the above file should page the value of the zend_extension as mentioned in xdebug custom installation oage.

Setting up PhpStorm with xdebug

  1. Start PhpStorm & on the main toolbar click image
  2. Select PHP on the left panel under Project Settings.
  3. Select PHP language level as 5.4 from the drop-down.
  4. Under Interpreter click Browse image button
  5. In Interpreter window click + button 1. Select interpreter path as /usr/bin/php. 2. Debugger as Xdebug
  6. Under PHP node inside image. Click on Servers. Add your service name and port. Select Debugger as Xdebug. The figure given below shows a service named indfas.alice running at port 80. image
  7. Add Debug Configurations. Click Run on the main toolbar of PhpStorm
  8. Select Debug and then Edit Configurations.
  9. Click +.
  10. Then select Php Web Application
  11. And then enter your Server, Start Url & Browser
  12. Click on Ok
  13. To debug add a breakpoint on the line (ctrl+shift+b) then click Run --> Debug from main toolbar.

Appendix

Install Php 5.4 on Ubuntu 12.04

By default the Php that is installed on Ubuntu 12.04 LTS is Php 5.3 but for Xdebug to work correctly we need Php 5.4. To install Php 5,4 please follow the stackoverflow link.

Troubleshooting

If the PhpStorm is facing trouble on connecting to xDebug please add the below environment variable:- export XDEBUG_CONFIG="idekey=PHPSTORM"

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