Yii2未知方法getHeaders

问题描述 投票:0回答:1

我已使用7.3.x更新了centos 7.x上的我的应用程序服务器,当我运行控制台命令时出现以下错误

/usr/local/zend/bin/php /var/www/html/cfms-hc/yii

下面是堆栈日志。

消息“正在调用未知方法:yii \ console \ Request :: getHeaders()”的异常“ yii \ base \ UnknownMethodException”在/var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Component.php:300中堆栈跟踪:#0 /usr/local/zend/var/plugins/yii2/zray/zray.php(158):yii \ base \ Component-> __ call('getHeaders',Array)#1 /usr/local/zend/var/plugins/yii2/zray/zray.php(43):Yii2-> getInfo()#2 /var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Controller.php(157):Yii2-> getPageInfo(Array,Array)#3 /var/www/html/cfms-hc/vendor/yiisoft/yii2/console/Controller.php(164):yii \ base \ Controller-> runAction('',Array)#4 /var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Module.php(528):yii \ console \ Controller-> runAction('',Array)#5 /var/www/html/cfms-hc/vendor/yiisoft/yii2/console/Application.php(180):yii \ base \ Module-> runAction('',Array)#6 /var/www/html/cfms-hc/vendor/yiisoft/yii2/console/Application.php(147):yii \ console \ Application-> runAction('',Array)#7 /var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Application.php(386):yii \ console \ Application-> handleRequest(Object(yii \ console \ Request))#8 / var / www / html / cfms-hc / yii(20):yii \ base \ Application-> run()#9 {main}消息“正在调用未知方法:yii \ console \ Request :: getHeaders()”的异常“ yii \ base \ UnknownMethodException”在/var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Component.php:300中堆栈跟踪:#0 /usr/local/zend/var/plugins/yii2/zray/zray.php(158):yii \ base \ Component-> __ call('getHeaders',Array)#1 /usr/local/zend/var/plugins/yii2/zray/zray.php(43):Yii2-> getInfo()#2 /var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Controller.php(157):Yii2-> getPageInfo(Array,Array)#3 /var/www/html/cfms-hc/vendor/yiisoft/yii2/console/Controller.php(164):yii \ base \ Controller-> runAction('',Array)#4 /var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Module.php(528):yii \ console \ Controller-> runAction('',Array)#5 /var/www/html/cfms-hc/vendor/yiisoft/yii2/console/Application.php(180):yii \ base \ Module-> runAction('',Array)#6 /var/www/html/cfms-hc/vendor/yiisoft/yii2/console/Application.php(147):yii \ console \ Application-> runAction('',Array)#7 /var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Application.php(386):yii \ console \ Application-> handleRequest(Object(yii \ console \ Request))#8 / var / www / html / cfms-hc / yii(20):yii \ base \ Application-> run()#9 {main}`在此处输入代码`

我不知道在哪里看,可能是什么问题。请引导任何人。

yii2
1个回答
0
投票

错误是因为您导入并使用了错误的Request类:

yii\console\Request::getHeaders();

查看console,控制台does not have the getHeaders() method.

您必须使用:

yii\web\Request::getHeaders();

https://www.yiiframework.com/doc/api/2.0/yii-web-request#getHeaders()

© www.soinside.com 2019 - 2024. All rights reserved.