Yii2 Console 'Class user does not exist'
<p>I'm trying to run <code>./yii</code> from my base directory.  I used the console application a few months ago and it worked then.  I'm not sure what changed.</p>

<p>I get the following error:</p>

<pre><code>Exception 'ReflectionException' with message 'Class user does not exist'

in /var/www/html/beta/fs2/vendor/yiisoft/yii2/di/Container.php:415

Stack trace:
#0 /var/www/html/beta/fs2/vendor/yiisoft/yii2/di/Container.php(415): ReflectionClass-&gt;__construct('user')
#1 /var/www/html/beta/fs2/vendor/yiisoft/yii2/di/Container.php(358): yii\di\Container-&gt;getDependencies('user')
#2 /var/www/html/beta/fs2/vendor/yiisoft/yii2/di/Container.php(151): yii\di\Container-&gt;build('user', Array, Array)
#3 /var/www/html/beta/fs2/vendor/yiisoft/yii2/di/Instance.php(154): yii\di\Container-&gt;get('user')
#4 /var/www/html/beta/fs2/vendor/yiisoft/yii2/di/Instance.php(128): yii\di\Instance-&gt;get(NULL)
#5 /var/www/html/beta/fs2/vendor/yiisoft/yii2/filters/AccessControl.php(98): yii\di\Instance::ensure('user', 'yii\web\User')
#6 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Object.php(107): yii\filters\AccessControl-&gt;init()
#7 [internal function]: yii\base\Object-&gt;__construct(Array)
#8 /var/www/html/beta/fs2/vendor/yiisoft/yii2/di/Container.php(372): ReflectionClass-&gt;newInstanceArgs(Array)
#9 /var/www/html/beta/fs2/vendor/yiisoft/yii2/di/Container.php(151): yii\di\Container-&gt;build('yii\filters\Acc...', Array, Array)
#10 /var/www/html/beta/fs2/vendor/yiisoft/yii2/BaseYii.php(344): yii\di\Container-&gt;get('yii\filters\Acc...', Array, Array)
#11 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Component.php(180): yii\BaseYii::createObject(Array)
#12 /var/www/html/beta/fs2/vendor/yiisoft/yii2/BaseYii.php(518): yii\base\Component-&gt;__set('as beforeReques...', Array)
#13 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Object.php(105): yii\BaseYii::configure(Object(yii\console\Application), Array)
#14 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Application.php(206): yii\base\Object-&gt;__construct(Array)
#15 /var/www/html/beta/fs2/vendor/yiisoft/yii2/console/Application.php(85): yii\base\Application-&gt;__construct(Array)
#16 /var/www/html/beta/fs2/yii(30): yii\console\Application-&gt;__construct(Array)
#17 {main}
</code></pre>

<p>How do I fix this?</p>

<hr>

<hr>

<p><strong>UPDATE</strong></p>

<p>After adding the parameters to my <code>console\config\main.php</code> file as suggested, I am now getting the following error:</p>

<pre><code>Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: yii\console\Request::getUserIP()'

in /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Component.php:285

Stack trace:
#0 /var/www/html/beta/fs2/vendor/yiisoft/yii2/filters/AccessRule.php(105): yii\base\Component-&gt;__call('getUserIP', Array)
#1 /var/www/html/beta/fs2/vendor/yiisoft/yii2/filters/AccessRule.php(105): yii\console\Request-&gt;getUserIP()
#2 /var/www/html/beta/fs2/vendor/yiisoft/yii2/filters/AccessControl.php(118): yii\filters\AccessRule-&gt;allows(Object(yii\base\InlineAction), Object(yii\web\User), Object(yii\console\Request))
#3 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/ActionFilter.php(71): yii\filters\AccessControl-&gt;beforeAction(Object(yii\base\InlineAction))
#4 [internal function]: yii\base\ActionFilter-&gt;beforeFilter(Object(yii\base\ActionEvent))
#5 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Component.php(541): call_user_func(Array, Object(yii\base\ActionEvent))
#6 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Module.php(607): yii\base\Component-&gt;trigger('beforeAction', Object(yii\base\ActionEvent))
#7 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Controller.php(139): yii\base\Module-&gt;beforeAction(Object(yii\base\InlineAction))
#8 /var/www/html/beta/fs2/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller-&gt;runAction('', Array)
#9 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller-&gt;runAction('', Array)
#10 /var/www/html/beta/fs2/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module-&gt;runAction('', Array)
#11 /var/www/html/beta/fs2/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application-&gt;runAction('', Array)
#12 /var/www/html/beta/fs2/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application-&gt;handleRequest(Object(yii\console\Request))
#13 /var/www/html/beta/fs2/yii(31): yii\base\Application-&gt;run()
#14 {main}
</code></pre>

<p>Here is my main config file:
</p>

<pre><code>$params = array_merge(
//    require(__DIR__ . '/../../common/config/params.php'),
//    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' =&gt; 'app-console',
    'basePath' =&gt; dirname(__DIR__),
    'bootstrap' =&gt; ['log', 'gii'],
    'controllerNamespace' =&gt; 'console\controllers',
    'modules' =&gt; [
        'gii' =&gt; 'yii\gii\Module',
    ],
    'components' =&gt; [
        'log' =&gt; [
            'targets' =&gt; [
                [
                    'class' =&gt; 'yii\log\FileTarget',
                    'levels' =&gt; ['error', 'warning'],
                ],
            ],
        ],
        'user' =&gt; [
            'class' =&gt; 'yii\web\User',
            'identityClass' =&gt; 'common\models\UserConsole',
            //'enableAutoLogin' =&gt; true,
        ],
    ],
    'params' =&gt; $params,
];
</code></pre>

<p>The directory <code>console\controllers</code> is empty.</p>