Debugging Mediawiki- Part 2 Installing XDebug

Spread the love

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. 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.

You may also like...

No Responses

  1. January 11, 2015

    […] 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/ […]

Leave a Reply

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