Roman Podlinov
Roman Podlinov

Reputation: 24944

Debug Yii console application in PHPStorm

PHPStrom is a great IDE. I really like it. But I bumped into an issue. I can't find instructions how to configure debugging for Yii console application. I set debugging for Yii web application and it works fine. Any help will be highly appreciated.

Upd1: Actually I figured out that there are 3 cases of the Yii console application.

Standard Yii console application (command files in the protected/commands folder of the webapp)

Standalone Yii console application (independent console aaplication without web application)

[My case] YiiBooster console application (YiiBooster has advanced, but good structure for medium or big projects)

Upvotes: 7

Views: 7397

Answers (3)

zhongyb
zhongyb

Reputation: 11

you just set your php.ini and add an parameter in like this:

xdebug.remote_autostart = 1

then you can debug your console application.

Upvotes: 0

Roman Podlinov
Roman Podlinov

Reputation: 24944

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)

Upvotes: 13

Related Questions