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

  1. 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.
  2. Install it and make sure that XDebug is activated (phpinfo() must return xdebug section in the response). Use the following link for detailed instructions enter image description here

  3. Set XDebug as debugger for PHP in Project Settings enter image description here

[The steps below are specific for Yii console application debugging]

  1. Find yiic.php file in your project and Run or Debug it first time. enter image description here

  2. After this go Run->Edit Config and set name of your command in the arguments with required parameters. enter image description here

  3. Now set breakpoints in your code and activate "Listen debugger connections” button. enter image description here

Debugging Yii command actions

  1. 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; }

  2. For debugging it needs to specify the action name in the arguments for yiic.php Run Configuration (see image above)

Tags:

Phpstorm

Yii