Reputation: 1995
I am looking to run a command in the cmd.exe from the yii2 application. I am on localhost and have admin rights.
The file I am trying to run the command from has the following path:
C:\Server\htdocs\hr\commands\EmployeecronController.php
The code looks like this:
class EmployeecronController extends Controller
{
public function actionIndex()
{
[Code]
}
}
This is what I enter into the console:
Upvotes: 0
Views: 120
Reputation: 1995
Ok, for me the problem was the following, I had to enter it like this:
C:\Server\htdocs\hr> C:/Server/php/php.exe yii employeecron
Upvotes: 0
Reputation: 33538
1) Make sure you placed controller in right folder:
commands
folder;console/controllers
folder.2) Make sure correct namespace is specified:
namespace app\commands;
;namespace console/controllers
;3) You need to call it like that:
php yii employeecron/index
or
yii employeecron/index
You can omit index because it's default action:
php yii employeecron
For complex controller and action names, for example LongContollerName
you need to separate it with dashes (as with regular web controllers):
php yii long-controller-name/long-action-name
Upvotes: 1