duanmibei1929 2016-08-05 10:12
浏览 138
已采纳

在linux服务器上设置未知属性:yii \ console \ ErrorHandler :: errorAction

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?

  • 写回答

2条回答 默认 最新

  • dongzhanlu0658 2016-08-05 13:10
    关注

    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',
    ];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • doushi9856 2016-08-05 10:49
    关注

    There is no errorAction attribute in yii\console\ErrorHandler class. There is one in yii\web\ErrorHandler though. I'm not sure why this works on your local machine because it shouldn't. I guess some other configuration is in place there.

    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于网上一个easyx制作的见缝插针小游戏(c++)
  • ¥15 开地址法双散列函数处理碰撞
  • ¥15 想问一下这个是什么情况 虚拟机Linux打不开了
  • ¥15 联通光猫掉注册了怎么重新注册上去
  • ¥15 关于unity开发steamvr程序遇到的问题
  • ¥60 求tc downloader的下载方式
  • ¥15 华为 快捷方式 手电筒 接口
  • ¥15 Qt6.5支不支持Android13开发啊
  • ¥20 网络只能跑一半,应该如何设置
  • ¥20 Python调用百度开发者平台人脸识别接口