Debug Yii console application in PHPStorm
After some period of time I found the solution. In my case it must be split in 2 parts:
Configure XDebug in PHPStorm
- Get appropriate Xdebug version. Use this wizard from official xdebug site; just copy&past your phpinfo() response into window and it will tell you which version you must download.
Install it and make sure that XDebug is activated (phpinfo() must return xdebug section in the response). Use the following link for detailed instructions
Set XDebug as debugger for PHP in Project Settings
[The steps below are specific for Yii console application debugging]
Find yiic.php file in your project and Run or Debug it first time.
After this go Run->Edit Config and set name of your command in the arguments with required parameters.
Now set breakpoints in your code and activate "Listen debugger connections” button.
Debugging Yii command actions
If you want to use actions (like actionRebuildIndexes) in the command it needs to call the parent::run method in the run() function.
public function run($args) { parent::run($args); return 0; }
- For debugging it needs to specify the action name in the arguments for yiic.php Run Configuration (see image above)