Debugging Mediawiki- Part 2 Installing XDebug

After a long time, I got some time to get back into Mediawiki development being mentor of the GCI program. So, gotta complete this long pending draft.
Here is the first version of this post- https://crondev.wordpress.com/2014/05/23/debugging-mediawiki-part-1/
The current and the next post aren’t targeted at Mediawiki alone, and are generic for any Web Application.

Here, we will set up XDebug- One of the most powerful debuggers for PHP developers
Now, assuming you have PHP installed(If not, do it now- For OS X , you need to activate PHP which is installed by default), let’s install XDebug.

Assuming you have PHP 5.5

* For OS X

sudo port install php55-xdebug

* For Linux

sudo apt-get install php55-xdebug

* For Windows: Download the precompiled distribution here

Now, let’s make PHP know that we installed this debugger. For that, edit your php.ini

Where to look for php.ini?
Usually it is found in /etc/php.ini in Linux and OS X. If you don’t have this file, look for /etc/php.ini.default and rename it to /etc/php.ini
Usually in the above mentioned places, or in the PHP folder. In Windows system, it is in the PHP installation folder.

Now here, we need to know where the xdebug.so is installed. For Windows, we simply downloaded the .dll file it, so no issues. For Linux and OS X, it is usually in /usr/lib/php/extensions/no-debug-SOMETHING/xdebug.so
Tip: Linux and OS X users can use locate xdebug.so

Editing the php.ini file
Now, time to edit the file. Add the following lines to it:

    zend_extension="xdebug.so PATH OBTAINED ABOVE"   

    [xdebug]
    xdebug.remote_enable=1
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
    xdebug.profiler_output_dir="SOME OUTPUT DIRECTORY"

Now let’s restart Apache, for OS X, use:

sudo apachectl restart

Let’s see if everything worked. In console type

php -v

If you get XDebug in this output, it means everything worked!!
Happy debugging!!

In the next post, I will discuss about how to integrate this debugger with PHPStorm, one of the most popular IDEs for PHP development.

Advertisements

One thought on “Debugging Mediawiki- Part 2 Installing XDebug

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s