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.