Closed qkdreyer closed 6 years ago
/cc @nicolas-grekas Can you validate this one please?
I confirm this resolves my issue with debug tag in toolbar, and also it resolves #95
But please check that this patch doesn't have any unwanted side effect on CLI apps.
This PR fix the issue for me.
In console mode I use \Knp\Provider\ConsoleServiceProvider()
and the \Silex\Provider\WebProfilerServiceProvider()
is not loaded.
In fact, the dump()
function work fine.
You need other test for merge ?
I can confirm this patch fixes the issue for plain Silex web applications.
@nicolas-grekas I think I know what you've meant ... After applying the patch, there's a tiny bug (maybe you can fix it @qkdreyer? ;) ): dump()
outputs the HTML twice outside of the application, e.g. placing a dump($app);
after $app->run();
will print the application's data twice. Without this patch there won't be any output et all.
@fabpot @nicolas-grekas Any news on this issue?
This fix works for me. Call of Symfony\Component\Debug\Debug::enable();
hide the Debug panel in profiler.
Minimal working examle (index.php in the root of fabpot/silex-skeleton):
<?php
use Silex\Application;
use Silex\Provider;
use Silex\Provider\WebProfilerServiceProvider;
use Symfony\Component\VarDumper\VarDumper;
require_once __DIR__.'/vendor/autoload.php';
//Symfony\Component\Debug\Debug::enable();
$app = new Application();
$app['debug'] = true;
$app->register(new Provider\HttpFragmentServiceProvider());
$app->register(new Provider\ServiceControllerServiceProvider());
$app->register(new Provider\AssetServiceProvider());
$app->register(new Provider\TwigServiceProvider());
$app->register(new Silex\Provider\VarDumperServiceProvider());
$app->register(new WebProfilerServiceProvider(), array(
'profiler.cache_dir' => __DIR__.'/../var/cache/profiler',
));
$app['twig.path'] = array(__DIR__.'/templates');
$app->get('/', function () use ($app) {
VarDumper::dump([1, 2, 3]);
dump([1, '2', 'three']);
return $app['twig']->render('index.html.twig', []);
});
$app->run();
Composer.json from fabpot/silex-skeleton with two new packages: symfony/var-dumper and symfony/debug-bundle
{
"name": "fabpot/silex-skeleton",
"description": "A pre-configured skeleton for the Silex microframework",
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"silex/silex": "~2.0",
"silex/web-profiler": "^2.0",
"symfony/asset": "~2.8|^3.0",
"symfony/browser-kit": "~2.8|^3.0",
"symfony/class-loader": "~2.8|^3.0",
"symfony/config": "~2.8|^3.0",
"symfony/console": "~2.8|^3.0",
"symfony/css-selector": "~2.8|^3.0",
"symfony/debug": "~2.8|^3.0",
"symfony/finder": "~2.8|^3.0",
"symfony/form": "~2.8|^3.0",
"symfony/monolog-bridge": "~2.8|^3.0",
"symfony/process": "~2.8|^3.0",
"symfony/security": "~2.8|^3.0",
"symfony/translation": "~2.8|^3.0",
"symfony/twig-bridge": "~2.8|^3.0",
"symfony/validator": "~2.8|^3.0",
"symfony/var-dumper": "^3.4",
"symfony/debug-bundle": "^3.4"
},
"autoload": {
"psr-0": { "": "src/" }
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"scripts": {
"run": [
"echo 'Started web server on http://localhost:8888'",
"php -S localhost:8888 -t web"
]
}
}
Thank you @qkdreyer.
Configuring the DumpListener before subscribing to its events, allowing it to correctly capture dump function calls in the WebProfilerToolbar