Basically, I have a function which sends ~1000 emails and I would like to make it as background process.
My yii2 set-up is the following:
Front-end is on "/" and back-end is under "/admin".
The questions is the following: I do not understand how to say which controller I would like to use? Does it determine by default which controller it is going to use?
Why don’t you use a console controller and invoke commands from console (so you can use it in crontab).
To make functions reusable, you can create a component to call from web controller or console controller (if you need to use functionalities from web).
Because more in general you can’t solve every needs using consoleRunner.
For example, if the action processes $_POST data, how would you pass $_POST parameters applying consoleRunner?
So I think that if doesn’t require too much work, It should be better put action content in a component that could be called from a console controller and web controller.
Anyway, for your request how have you built consoleRunner object? How have you defined ‘file’ parameter?
It should be similar at:
components [
'consoleRunner' => [
'class' => 'vova07\console\ConsoleRunner',
'file' => '@my/path/to/yii' // or an absolute path to console file
]
]
If POST request is coming from the form on controller "add/signal", I would like to send POST request to "signal\email" which is sending emails ~1000 emails to people, however I would like to make "signal\email" as a background process, otherwise, it will take forever for a person to wait for the reply.
Btw, console runner does not for some reason. I have tried vova’s class as well. Also, I would like to execute controller from backend, not frontend.