A
A
Alexander Vanin2019-08-16 16:18:02
Yii
Alexander Vanin, 2019-08-16 16:18:02

Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: yii\console\Application::getSession()'. What to do?

It just so happened that I need to give a command on the web application to launch the action of the console controller to simulate background processing of a request from an outside service and then fill in the table column in the database with the received data (through the model). I call an action in the web controller, which calls the console controller, namely the action, which should form a queue and then run it. However, when I run this action, an exception is thrown with the text 'Calling unknown method: yii\console\Application::getSession()'.
I want to say right away that in the console config there is the following code:

'components' => [
        //...another code
            'session' => [ // for use session in console application
                'class' => 'yii\web\Session'
            ],
        ],

I found the same issue on GitHub, but it was abandoned without an answer. What can cause this problem and how to solve it, maybe someone faced?
UPD: the getSession() method is called by the behavior of the model that I have to access. There is a component in the configs that should redefine the concept
yii\console\Application::getSession()on yii\web\Application::getSession()
However, this does not happen :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-08-16
@byBack00

The session is not needed in the console and, in principle, it is not there. Therefore, the error. Translate the error. It's clear though:
Session (session) is a certain period of time within which a web application can determine all requests from one client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question