In order to debug symfony or php apps that uses front end controller approach, you need to have several things:
- Configure Xdebug. I prefer to use the
On-Demand mode, but beware that it's only applicable to cli scripts / code coverage reports. Make sure that you set thexdebug.mode=debugandxdebug.idekey=PHPSTORM. This will be usefull in case you need to Debugging Symfony commands.
- To debug incoming http request, you need to have a webserver running configuration. We'll use the
PHP Built-in Web Serveras it's sufficient for our purpose. Click Run > Edit Configurations > Add New Configuration > PHP Built-in Web Server. Use port8000and document root to be$PROjECT_DIR/publicwhere$PROjECT_DIRis the path of your project. Sadly, since XdebugOn-Demand modeis not working for this web server, you need to have separatephp.iniconfig and use that for theInterpreter options. Here I set it as-c /home/rizalp/Dropbox/appConfig/php/lib/php.xdebug.ini. InEnvironment Variablesfield, addXDEBUG_SESSION=1to activate the debugger. ClickOkto save the configuration. Name itSymfony PHP Serveror anything.
To start debugging
- Put breakpoint on the line that you want to debug
- Run >
Start Listening for PHP Debug Connections - Run >
Run Symfony PHP Server - There will be dialog window from the PHPStorm about the incoming connections from xdebug. Click
Accept. - Send http request. The execution will break at the line where you put the breakpoint


