Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you run console jobs from yii2-basic?

Tags:

yii

yii2

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.

like image 302
Martin Avatar asked Mar 17 '15 02:03

Martin


1 Answers

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.

like image 53
arogachev Avatar answered Oct 18 '22 08:10

arogachev