Toricima Toricima - 3 months ago 28
Linux Question

Setting unknown property: yii\console\ErrorHandler::errorAction on linux server

I just uploaded my yii advanced project to my centos server, but I can't seem to get past the migrate phase. When I try to run yii migrate the following error occurred:

`Setting unknown property: yii\console\ErrorHandler::errorAction'

I have no idea why this happens, because it works fine when I run it locally on my windows computer.

My yii advance project is bit different than a normal Yii advanced. The backend has been separated from the frontend so it just contains the console and frontend directory.

common/config/main.php

$config = require(__DIR__ . '/main-console.php');
array_push($config['bootstrap'], 'site');
$config['components']['errorHandler'] = [
'errorAction' => 'site/error',
];
$config['components']['user'] = [
'identityClass' => 'frontend\models\User',
'enableAutoLogin' => true,
];

$config['components']['session'] = [
'name' => 'PHPFRONTSESSID',
'savePath' => sys_get_temp_dir(),
];

$config['components']['request'] = [
'cookieValidationKey' => 'IBzCJMjLWUaXMZemYUej',
'csrfParam' => '_frontendCSRF',
];

$config['components']['site'] = [
'class' => 'frontend\components\SiteComponent',
];

return $config;


main-console.php

$params = array_merge(
require(__DIR__ . '/params.php')
);

return [
'id' => 'app-frontend',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log','debug'],
'sourceLanguage' => 'en-US',
'controllerNamespace' => 'frontend\controllers',
'aliases' => [
'@local_media' => '@frontend/web/uploads/media',
],
'modules' => [
'debug' => [
'class' => 'yii\debug\Module',
],
],
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@frontend/messages',
],
],
],
'assetManager' => [
'bundles' => false,
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning', 'trace'],
],
],
],
'defaultRoute' => 'site/view',
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => true,
'enableStrictParsing' => false,
'rules' => require('routes.php'),
],
],
'params' => $params,
];


Can someone give me some advies on how to solve this problem?

Answer

You problem is that you specify error action into common/config/main.php. Error action must be used only with web apps, not console. So move this to your frontend and backend configs separately:

$config['components']['errorHandler'] = [
    'errorAction' => 'site/error',
];
Comments