Uh, Hey, I Need Some Help Getting the Yii Debug Toolbar to Show in Yii 3 App

Hey everyone—uh, I’m having kinda a hard time with this Yii 3 thing. I’m working on an app using that official yiisoft/app template, but, well… the debug toolbar just won’t show up no matter what I do, and it’s driving me a little crazy.

So here’s what I’ve done so far, and I think I did it right, but who knows, right?

My .env file has:

YII_ENV=dev
YII_DEBUG=true

I checked the environment vars using var_dump($_ENV['YII_ENV'], $_ENV['YII_DEBUG']); and they look like they’re loaded okay.

In config/environments/dev/params.php I put this in:

return [
    'yiisoft/yii-debug' => [
        'enabled' => true,
    ],
];

Then, ‘cause I heard about that scary .merge-plan.php error, in config/web/params.php I just directly load the env params and make a flat 'debugEnabled' flag, like this:

<?php
declare(strict_types=1);

$env = $_ENV['YII_ENV'] ?? 'prod';
$envParamsFile = __DIR__ . '/../environments/' . $env . '/params.php';
$envParams = file_exists($envParamsFile) ? include $envParamsFile : [];

$debugEnabled = isset($envParams['yiisoft/yii-debug']['enabled'])
    ? (bool)$envParams['yiisoft/yii-debug']['enabled']
    : false;

return [
    'debugEnabled' => $debugEnabled,
    // other params if you want…
];

In config/web/providers-web.php, I tell Yii to make the debug module only if that debugEnabled bool is true:

'modules' => [
    'debug' => function (bool $debugEnabled) {
        if (!$debugEnabled) {
            return null;
        }
        $module = new \Yiisoft\Yii\Debug\Module();
        $module->allowedIPs(['127.0.0.1', '::1']);
        return $module;
    }
],

I cleared all the runtime caches, and I’m accessing the app from 127.0.0.1 (so IP shouldn’t be the problem, I guess).

And in public/index.php the debug flags are passed properly to the runner.


But it’s still not showing!


So I’m asking you friendly geniuses:

  • Am I missing some super obvious or weird step to get this debug toolbar to appear?
  • Does the official yiisoft/app template have sneaky stuff that might block it?
  • How do I even check if the debug module is running or totally dead?
  • Is there a stupid-simple minimal example for a Yii 3 app that shows the toolbar like a boss?

Any pointers would be really appreciated — I’m getting stressed! Thanks a bunch!


Mort out.

Hi,

I couldn’t get it working either, so I ported the Tracy Debugger. It uses the Yii debug collectors, so the information is the same. It’s simple to install and set up and it’s helped me optimise some queries.

I’ve structured the project as the main Tracy Port and separate panels, so you only install what you need. Currently there are panels for:

To install add the panels you want to the require-dev section of your composer.json.

Do take a look at the README for the yii-tracy package (a dependency of the panels) for more installation info.

It displays as a floating bar with a summary of each panel. Panels are displayed by hovering over the summary and can be “fixed” by clicking on the summary.


The floating bar


The database panel expanded

If you decide to give it a try please let me know how it goes.

Best regards,
Chris

2 Likes