php Yii2未知方法getHeaders

jutyujz0  于 2023-09-29  发布在  PHP
关注(0)|答案(2)|浏览(142)

我已经更新了我的应用程序服务器上centos 7.x与php 7.3.x这给出了以下错误时,我运行控制台命令,如

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

以下是堆栈日志。

Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: yii\console\Request::getHeaders()'

in /var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Component.php:300

Stack trace:
#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}

Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: yii\console\Request::getHeaders()'

in /var/www/html/cfms-hc/vendor/yiisoft/yii2/base/Component.php:300

Stack trace:
#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}

我不明白在哪里看,什么可以的问题。请指导任何人。

fsi0uk1n

fsi0uk1n1#

错误是因为您导入并使用了错误的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()

sirbozc5

sirbozc52#

我正在使用Zend Server,只是禁用了Zray。问题解决了

相关问题