this is the first time I try to debug a Symfony 2.7 installation with xdebug inside PHPStorm 9.0. Apache is running on the same system where PHPStorm is installed. The basic setup works so PHPStorm is connected with xdebug, breaks on the first line and stops on the next breakpoint when I press F9. My problem is: the debugger does not stop inside my own bundles in Symfony2. It seems that the Symfony2 structure "confuses" PHPStorm. The debugger only stops in some main symfony2 files like app.php or AppKernel.php.
Let's start with my configuration:
- PHPStorm 9.0
- Apache/2.2.22 (Debian)
- Xdebug v2.2.1
- PHP Version 5.4.45-0+deb7u1
- Iceweasel 31.8.0 with Booklets (https://www.jetbrains.com/phpstorm/marklets/)
xdebug.conf
zend_extension=/usr/lib/php5/20100525/xdebug.so
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_log=/var/log/xdebug-remote.log
xdebug.remote_autostart=0
xdebug.var_display_max_children=512
xdebug.var_display_max_data=32000
xdebug.var_display_max_depth=8
Everything in xdebug remote log looks fine and I find all my breakpoints which I set in PHPStorm. I also can open files with VIM using the file:// path which I can see inside the xdebug log.
My conclusion: there is no mapping problem, right? To be really save I mapped all folders in PHPStorm settings. It still does not work...
Breakpoint in symfony/app/AppKernel.php works:
<- breakpoint_set -i 11 -t line -f file:///var/www/myDomain.de/symfony/app/AppKernel.php -n 23
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="11" id="110380033"></response>
Breakpoint in own bundle in SmartphoneController.php does not work (PHPStorm debugger does not stop):
<- breakpoint_set -i 12 -t line -f file:///var/www/myDomain.de/symfony/src/Pce/Bundle/BackendBundle/Controller/SmartphoneController.php -n 32
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="12" id="110380034"></response>
To be sure that the codeline is executed I saved some test string in a global $_SERVER variable:
$_SERVER['TEST_FOR_DEBUG'] = 'Am I executed? YES!';
var_dump($_SERVER['TEST_FOR_DEBUG']);
My conclusion: the xdebug - PHPStorm setup generally works (debugger stops in AppKernel.php).
Ok, maybe there is a problem with Symfonys caching and PHPStorm comes into trouble referencing the right files. I found these articles to disable Symfonys caching to "help the IDE":
- Debugging Symfony components: https://www.adayinthelifeof.nl/2014/12/31/debugging-symfony-components/
- Disabling Symfony Cache: github.com/symfony/symfony-standard/pull/393
- How to Optimize your Development Environment for Debugging: symfony.com/doc/current/cookbook/debugging.html
- Symfony2 aided by PhpStorm: craftitonline.com/2011/06/symfony2-aided-by-phpstorm/
Based on these articles I called the Dev-Environment (app_dev.php) and disabled the caching before:
$loader = require_once __DIR__.'/../app/autoload.php';
Debug::enable();
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
// CHANGE: Comment the next line to disable cache loading
//$kernel->loadClassCache();
$request = Request::createFromGlobals();
No luck! Does anybody know what I can do?
/var/www/myDomain.de/symfony/src/Pce/Bundle/BackendBundle/Controller/SmartphoneController.php
. Xdebug works with final/resolved URLs only while PhpStorm works with paths as is. If symbolic link is present then update your path mappings accordingly. – LazyOnexdebug_break();
(programmatic breakpoint) in such file instead of actual IDE breakpoint. Xdebug will definitely break there (as long as that file/line gets executed, of course). If IDE will not catch up such breakpoint then most likely it cannot map that remote file to the local project (e.g. file is outside of the project / no or bad path mapping etc) -- you will have to see details of that in xdebug log. – LazyOne$a = 22;
before your desired breakpoint and put breakpoint there -- will it break there?). – LazyOne