yiisoft/yii2 · error · yii\console\Exception

"{get_class($this)}::assetManager" should be either object o

Error message

"{get_class($this)}::assetManager" should be either object or array - "{gettype($assetManager)}" given.

What it means

Error ""{get_class($this)}::assetManager" should be either object or array - "{gettype($assetManager)}" given." thrown in yiisoft/yii2.

Source

Thrown at framework/console/controllers/AssetController.php:182

            if (!isset($options['forceCopy'])) {
                $options['forceCopy'] = true;
            }

            $this->_assetManager = Yii::createObject($options);
        }

        return $this->_assetManager;
    }

    /**
     * Sets asset manager instance or configuration.
     * @param \yii\web\AssetManager|array $assetManager asset manager instance or its array configuration.
     * @throws \yii\console\Exception on invalid argument type.
     */
    public function setAssetManager($assetManager)
    {
        if (is_scalar($assetManager)) {
            throw new Exception('"' . get_class($this) . '::assetManager" should be either object or array - "' . gettype($assetManager) . '" given.');
        }
        $this->_assetManager = $assetManager;
    }

    /**
     * Combines and compresses the asset files according to the given configuration.
     * During the process new asset bundle configuration file will be created.
     * You should replace your original asset bundle configuration with this file in order to use compressed files.
     * @param string $configFile configuration file name.
     * @param string $bundleFile output asset bundles configuration file name.
     */
    public function actionCompress($configFile, $bundleFile)
    {
        $this->loadConfiguration($configFile);
        $bundles = $this->loadBundles($this->bundles);
        $targets = $this->loadTargets($this->targets, $bundles);
        foreach ($targets as $name => $target) {
            $this->stdout("Creating output bundle '{$name}':\n");

View on GitHub (pinned to 66f00d18a2)

When it happens

Trigger: Thrown at framework/console/controllers/AssetController.php:182 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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