yiisoft/yii2 · error · InvalidConfigException

Unknown bootstrapping component ID: $mixed

Error message

Unknown bootstrapping component ID: $mixed

What it means

Each entry of config['bootstrap'] runs at application startup. A string entry is resolved first as an application component ($app->has($id)), then as a module ($app->hasModule($id)); if it is neither and contains no backslash (so it cannot be a class name for Yii::createObject()), the id refers to nothing known and InvalidConfigException('Unknown bootstrapping component ID: ...') is thrown. A closure entry or a backslash-containing class string never triggers this - only plain, unresolved ids do.

Source

Thrown at framework/base/Application.php:315

                    Yii::debug('Bootstrap with ' . get_class($component), __METHOD__);
                }
            }
        }

        foreach ($this->bootstrap as $mixed) {
            $component = null;
            if ($mixed instanceof \Closure) {
                Yii::debug('Bootstrap with Closure', __METHOD__);
                if (!$component = call_user_func($mixed, $this)) {
                    continue;
                }
            } elseif (is_string($mixed)) {
                if ($this->has($mixed)) {
                    $component = $this->get($mixed);
                } elseif ($this->hasModule($mixed)) {
                    $component = $this->getModule($mixed);
                } elseif (strpos($mixed, '\\') === false) {
                    throw new InvalidConfigException("Unknown bootstrapping component ID: $mixed");
                }
            }

            if (!isset($component)) {
                $component = Yii::createObject($mixed);
            }

            if ($component instanceof BootstrapInterface) {
                Yii::debug('Bootstrap with ' . get_class($component) . '::bootstrap()', __METHOD__);
                $component->bootstrap($this);
            } else {
                Yii::debug('Bootstrap with ' . get_class($component), __METHOD__);
            }
        }
    }

    /**
     * Registers the errorHandler component as a PHP error handler.

View on GitHub (pinned to 66f00d18a2)

Solutions

  1. Add the matching entry under 'components', e.g. 'queue' => ['class' => \yii\queue\file\Queue::class]
  2. Or register the id under 'modules' if it is a module
  3. Or use a fully qualified class name with a backslash ('app\bootstrap\SettingsLoader') so Yii::createObject() instantiates it directly
  4. Or delete the stale entry from the bootstrap array

Example fix

// before
return [
    'bootstrap' => ['queue'],
    'components' => [], // queue never configured
];

// after
return [
    'bootstrap' => ['queue'],
    'components' => [
        'queue' => ['class' => \yii\queue\file\Queue::class],
    ],
];
Defensive patterns

Strategy: validation

Validate before calling

foreach ((array)($config['bootstrap'] ?? []) as $entry) {
    if (is_string($entry)
        && !isset($config['components'][$entry])
        && !isset($config['modules'][$entry])
        && strpos($entry, '\\') === false) {
        throw new \InvalidArgumentException("bootstrap entry '{$entry}' resolves to nothing");
    }
}
$app = new \yii\web\Application($config);

Try / catch

try {
    $app = new \yii\web\Application($config);
} catch (\yii\base\InvalidConfigException $e) {
    // message starts with 'Unknown bootstrapping component ID:'
    error_log($e->getMessage() . ' - check the bootstrap array vs components/modules');
    throw $e;
}

Prevention

When it happens

Trigger: 'bootstrap' => ['queue'] when no 'queue' component exists; removing or renaming a component but leaving its old id in bootstrap; extension install guides (debug, gii, queue) where you copied the bootstrap line but not the matching 'components' block; expecting a module id like 'admin' to bootstrap without registering it under 'modules'.

Common situations: Copying bootstrap arrays between projects whose component sets differ; partial extension enabling; typos in bootstrap ids.

Related errors


AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17). Data as JSON: /api/errors/5fae60995593c9ce. Report an issue: GitHub.