0
votes

I have updated my application server on centos 7.x with php 7.3.x which gives following error when i run console command like

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

Following is stack log.

        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}`enter code here`

I can not understand where to look and what can be the problem. Plz guide anyone.

2
Are you using Yii2 advanced-app? can you add your common/config.php and console/config.phpMuhammad Omer Aslam
From stack trace it looks like plugin zray assumes to be executed via HTTP request, not CLI command. I would suggest replacing zray (which is a component from Zend Framework) with Yii2 debugger bar - github.com/yiisoft/yii2-debug.lubosdz
I am using basic app and using console/config.php. and this problem comes only on linux.Waseem Hassan
@lubosdz Thanks for hint. I am using Zend Server for production and zray was enabled there. I have disabled and problem is resolved.Waseem Hassan

2 Answers

1
votes

The error is because you are importing and using the wrong Request class:

yii\console\Request::getHeaders();

Look at the console, console does not have the getHeaders() method..

You must use:

yii\web\Request::getHeaders();

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

1
votes

I was using Zend Server for and just disabled Zray on it. Problem solved