Showing posts with label DBGp. Show all posts
Showing posts with label DBGp. Show all posts

Monday, November 30, 2015

Debugging Symfony with XDebug

Many times the information from the Symfony Debugger is enough to figure what's the problem, but sometimes I need to debug using XDebug. When I tried to debug my code using XDebug (with Notepadd++ and DBGp plugin)  I noticed that my breakpoints were ignored.. hmm weird.
 Because of the caching done by Symfony those breakpoints are never reached because that code is not executed. In order to overcome this issue the app_dev.php should be changed.

Source:  https://www.adayinthelifeof.nl/2014/12/31/debugging-symfony-components/

    // CHANGE: Change from bootstrap.php.cache to autoload.php
    $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();
A more complex solution can be found here:
https://gist.github.com/johnkary/601b4071a4b923b22ac2

I wrote  on how to use Notepad++ with XDebug  on this post.