0

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}

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

4
  • Are you using Yii2 advanced-app? can you add your common/config.php and console/config.php Commented Mar 6, 2020 at 17:32
  • 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. Commented Mar 6, 2020 at 21:31
  • I am using basic app and using console/config.php. and this problem comes only on linux. Commented Mar 7, 2020 at 10:21
  • 1
    @lubosdz Thanks for hint. I am using Zend Server for production and zray was enabled there. I have disabled and problem is resolved. Commented Mar 7, 2020 at 10:45

2 Answers 2

1

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()

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.