Quantcast
Channel: A Day In The Life Of...
Viewing all articles
Browse latest Browse all 59

Debugging Symfony components

$
0
0

Don’t you hate it when you are stepping through your debugger during a Symfony application debug session, and all of a sudden it cannot find files anymore as Symfony uses code located in the bootstrap.php.cache instead of the actual Symfony component. Symfony creates these cache-classes in order to speed up execution, but it makes that xdebug cannot find the correct code to step through anymore.

It’s probably posted many times already, but I couldn’t find it so I’m adding it to my blogpost as well, but it’s an easy fix. In your app_dev.php, change the following:

 

// 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();

From this point on, Symfony will use the original code which you can easily step through.

Share


Viewing all articles
Browse latest Browse all 59

Trending Articles