Enable Xdebug & Code Coverage In PHPStorm 4

Enable Xdebug & Code Coverage In PHPStorm 4

PHPStorm has released version 4 last month. Our license enables us to freely upgrade PHPStorm until Feb next year, so why not? There are a few features that come with version 4, you can have a look at here if you are interested, but I am more interested in the one called “Code Coverage for PHPUnit”. I will detail in the following on what I did to get it working. Firstly I enabled Xdebug on my MAMP installation by update the correct php.ini file. For my instance it is in file “/Applications/MAMP/conf/php5.3/php.ini”, find the following line in your file and uncomment it:
Restart your apache server and you should be able to find the xdebug section from your phpinfo(); Now open PHPStore’s preference and select PHP from left side, and choose “Xdebug” for Debugger: Then setup PHPUnit for your project, my configuration looks like this: Now I am able to run the test by clicking on the “Run <project> with coverage” command: After running the test with coverage, I can see the report on my project: And it also highlights in the file which lines are covered (green) and which lines are not covered (red) by giving appropriate colors on each line: Now I know exactly how my code is covered and how to fix them directly inside the IDE.


Leave a Reply

Your email address will not be published. Required fields are marked *

My new Snowflake Blog is now live. I will not be updating this blog anymore but will continue with new contents in the Snowflake world!