Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug Yii console application in PHPStorm

Tags:

phpstorm

yii

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)

like image 583
Roman Podlinov Avatar asked May 16 '13 13:05

Roman Podlinov


People also ask

How do I debug using xdebug?

You can find it in the extension window and install it. After installation, you must reload the VSCode window. Now, again run phpinfo(); method in any PHP file to check if Xdebug is enabled or not. Now click on the debug console tab and click on add configuration.

What is Xdebug_session_start Phpstorm?

inurl:?XDEBUG_SESSION_START=phpstorm. Google Search: inurl:?XDEBUG_SESSION_START=phpstorm. #Google Dork : inurl:?XDEBUG_SESSION_START #Summary: Xdebug is a php extension that allows to debug php pages, remotely by using DGBp protocol. - Code execution is possible through eval or property_set xdebug commands. -


2 Answers

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)
like image 172
Roman Podlinov Avatar answered Nov 07 '22 17:11

Roman Podlinov


There is article in jetbrains blog about it.

like image 29
Pitoziq Avatar answered Nov 07 '22 15:11

Pitoziq