How to set up remote debugging for symfony2 with phpstorm and xdebug How to set up remote debugging for symfony2 with phpstorm and xdebug symfony symfony

How to set up remote debugging for symfony2 with phpstorm and xdebug


i've just finished setting up my local symfony2 app and phpstorm debugging with Chrome, here is what i've done:

1) config xdebug in php.ini on the server and restart web server (or php-fpm):

[xdebug]zend_extension="**location to xdebug**/xdebug.so"xdebug.remote_enable = 1; use port 9009 because php-fpm uses 9000 by defaultxdebug.remote_port = 9009xdebug.idekey = PHPSTORM

2) install xdebug extensionhttps://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc

3) setup xdebug exteions. in chrome://extensions find Xdebug helper and click options. there select IDE key to PhpStorm. (this will essentially set xdebug.idekey to PHPSTORM for that particular session)

4) now the trickiest part, connecting from PhpStorm.you have to setup PHP Remote Debug debug configuration.

  1. in the toolbar, next to the debug button, you have drop down field with the first option Edit configuration. it opens Run/Debug Configurations.
  2. there click the + button and add PHP Remote Debug.
  3. specify your name, server and Ide key = PHPSTORM.
  4. click Apply and Ok (i never know which one so i always click both, just in case)
  5. now the dropdown in the toolbar will show your newly set remote server, run button (green arrow) will be disabled.
  6. click Start Listen for PHP Debug Connection
  7. click that green bug icon to start debugging
  8. Debug view will open with 2 tabs: Debugger and Console (selected by default)
  9. change the tab to Debugger and you will see: "Waiting for incoming connection with the ide key 'PHPSTORM'"
  10. open your browser
  11. navigate to your server url
  12. activate Xdebug helper extension (clicking on that gray bug in the url bar) it will turn green
  13. to check that everything is ok, open Chrome console, tab Resources -> Cookies -> your server. and verify that cookie XDEBUG_SESSION with value PHPSTORM was created (this is what actually activates xdebug remote debugging in php)
  14. now refresh the page and quickly alt-tab back to PhpStorm (or arrange your windows so you can see PhpStorm while refreshing browser)
  15. in your Debug view and Debugger console you will briefly see "Connected"

TADA!

create couple of break points in controller (dont use AppKernel.php or other symfony2 specific files as those get compiled and are not called, even in dev mode)


added 5.1.2015

official tutorial can be found here:https://confluence.jetbrains.com/display/PhpStorm/Profiling+PHP+applications+with+PhpStorm+and+Xdebug


Everything worked, up to the point where I set a breakpoint. Since Symfony2 is a front controller, it doesn't know which corresponding file matches the breakpoint. I tried to setup path mappings, but to no avail.

Invalid path mappings