Final post in this series, where we will integrate our debugger with PHPStorm.
Here is the previous post- https://crondev.wordpress.com/2014/12/14/debugging-mediawiki-part-2-installing-xdebug/
To start with, PHPStorm has been my favourite IDE for everything, it just is too clean and brilliant. Not discussing it’s frills here- check them on the website here.
And know what, Mediawiki developers get a free licensed version of PHPStorm!!
To start with, I am assuming that you have PHP and XDebug set up. If not, set up using instructions in this post.
Now download PHPStorm and install it as given in instructions. For Linux, extract it, and it can be launched using
./phpstorm in the folder where it was extracted. For OS X, simply install it and launch using icon.
Now you can create a New project and use the MediaWiki directory for the same.
Let’s integrate PHP and our debugger into it. Open Preferences->PHP and click on the … button beside Interpreter. We need to add our PHP interpreter to this. Click the + button in the new window to add an interpreter. By default, it will suggest the usual path i.e. /usr/bin/php and that works usually. For windows, you might need to navigate to the correct folder.
Now, click OK and we successfully installed the PHP interpreter. You may want to change the PHP language level to choose but it is optional.
Let’s make PHPStorm work with the debugger. For this, go to Debug and set the Debug port under XDebug same as what we set in the php.ini file.
Click on Validate Remote Environment, and Deployment server. Here we will need to create a new Server. Since, I was working with localhost, I used an In place server.
Now, go to Mappings, and map the absolute path of the application to the path of the directory. For eg I mapped /Users/kunal/Sites/Mediawiki to /~kunal/Mediawiki since it was accessible using http://localhost/~kunal/Mediawiki/index.php
Here is a screenshot of Special:SpecialPages application. You can now add breakpoints anywhere to stop and analyse the code. For instance, see the screenshot of debugging the Special:SpecialPages application we just created.
If everything worked, you are good to go! The same can be applied for other PHP applications as well.
Thanks for reading this post, Signing off now.