I am aware that Yii2-advanced has the ability to run console jobs (php yii controllername) but I was wondering if the basic app has the same ability? I notice a console.php file in the config folder, but cannot seem to get the jobs to run.
If it is possible, can someone give an example - where does the controller go (since I put it in controllers, but I get the message 'Error: Unknown command test' when trying php yii test)
Any help appreciated.
Yes, the same functionality exists in the basic template too.
However, it's organized a bit differently.
By default the console controllers are located in commands folder (you can change that by editing this setting: 'controllerNamespace' => 'app\commands'
).
Configuration is managed through config/console.php
that you mentioned.
As for example you can take a look at HelloController which comes with template by default.
You can find more info in according official docs section.
As for you error, accurately check controller name and its action names, most likely the problem is there.
Update: Make sure you have at least one action in this controller, otherwise the same error ("Unknown command") will appear.
You can list all available commands with php yii
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With