How to debug a Yii2 project with XDebug and PHPStorm IDE
What’s up, guys! Today we are talking about debugging and a debugger. First of all I have to notice you that this article for beginners wants to have an ability to debug their own Yii2 project in powerful IDE PHPStorm with XDebug.
Get started. In my case I used next instruments:
- Apache 2.4
- PHP 5.5
- Chrome browser with JetBrains IDE Plugin 2.8
- PHPStorm 9
- xDebug 2.2.6
Step 1. In your php.ini find a section [Xdebug] and uncomment directives below:
zend_extension=”YOUR_PATH_TO_PHP/ext/php_xdebug.dll” xdebug.default_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_enable = 1
xdebug.remote_port = 9001
After that you should check out your php configuration through phpinfo() function. If you can find xdebug in properties list this mean you have configured the xDebug right.
Step 2. Go to PHPStorm->File->Settings->Language & Frameworks
You should set up development environmental in php-interpretation part some like this:
Step 3. Then go to PHPStorm->File->Settings->Language & Frameworks->PHP->Server and set up your webserver’s options:
Step 4. In PHPStorm->File->Settings->Language & Frameworks->PHP->Debug configure xDebug settings:
Step 5. In top right corner of the PHPStorm select “Edit Configurations…” option
Step 6. In appeared window click on “+” and add “PHP Web Application”.
That’s all. Next step is set breakpoints by clicking on left side of an editor against some functions or other entities that you want to explore.
Click on a bug icon in top panel
Result may looks like on an image below:
Thanks for reading!