Skip to main content

Install & Configure Xdebug on XAMPP Windows and Mac

Xdebug is one of the most popular debugger as well as a profiler for PHP. In this post, we will learn to configure xdebug on XAMPP for both windows and mac osx operating system.

Steps to Install and Configure Xdebug on XAMPP Windows

Installing and configuring Xdebug for XAMPP on a windows machine is quite easier than installing on Linux or Mac. This is because you can get compiled version of xdebug very eaisly from internet. All you need to do is to get compiled version of xdebug and put it in your PHP extension directory, add configuration in php.ini file and restart the apache.

steps to install xdebug on XAMPP windows

  1. Go to Xdebug Download Page and choose your appropriate binary for your xampp installation.
  2. Copy the downloaded DLL file into your XAMPP php extension directory. For my case it is at C:\xampp\php\ext directory.
  3. Now open your PHP.ini file and add the below configuration. For me PHP.ini file is at c:\xampp\php\php.ini
    zend_extension=c:\xampp\php\ext\xdebug.dll
    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_host=localhost
    xdebug.remote_autostart = 1
    xdebug.remote_port=9000
    xdebug.show_local_vars=1
  4. Just restart your apache from xampp utility. That is it. Now you have your xdebug installed on xampp.

Steps to Install and Configure Xdebug on Mac OSX

  1. Download xdebug suitable version of xdebug from xdebug.org website. I have downloaded xdebug-2.4.0
  2. Open a command terminal and go to download folder and unzip the downloaded archive. For example, after downloaded from step #1 I have used cd ~/download command to go into the download folder and then hit tar xvzf xdebug-2.4.0.tgz command.
  3. Go to the extracted folder by hitting command cd xdebug-2-4-0 command.
  4. Run the phpize command. But make sure that you are hitting phpize from your xampp phpize and your php should be xampp. PHP Command will give output like below
    Configuring for:
    PHP Api Version:         20151012
    Zend Module Api No:      20151012
    Zend Extension Api No:   320151012
  5. Now, configure with XAMPP PHP configuration by hitting below command on your command terminal.
    ./configure --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config
  6. Run the make command on the command terminal. Just type make and hit enter.
  7. Once you will hit make command then you will go to your ~/Downloads/xdebug-2.4.0/modules directory then you can see a .so file with name xdebug.so.
  8. Now, all you need to do is to just copy your xdebug.so file into your xampp extension folder. Since we are in xdebug-2.4.0 folder on terminal just hit below command.
    sudo cp modules/xdebug.so /Application/XAMPP/xamppfiles/lib/php/extensions/xdebug.so
  9. Almost you are done. Open your PHP.ini file and put below configuration for basic xdebug enablement:
    zend_extension=/Applications/XAMPP/xamppfiles/lib/php/extensions/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_host=localhost
    xdebug.remote_autostart = 1
    xdebug.remote_port=9000
    xdebug.show_local_vars=1
    xdebug.remote_log=/Applications/XAMPP/logs/xdebug.log
  10. Restart the apache and open your PHPinfo file by hitting http://localhost/dashboard/phpinfo.php on your browser and search for xdebug on the phpinfo and you will something like below:
    Xdebug XAMPP MAC OSX

Troubleshouting of xdebug on XAMPP MAC OSX

Below are some of the issue you will face while installing Xdebug for XAMPP on mac.

  1. PHP and PHPIZE path: Just make sure that your PHP and PHPIZE are from XAMPP not from any other source. You can check it by running which php and which phpize command. If you do not found PHP and PHPIZE from XAMPP then first change your environment variable of PHP and PHPIZE.
  2. Read Write Permission: Most of the time when you will try to copy xdebug.so into xampp from your normal user then it won’t allow you to do this. So always use sudo command.

Support Me by Sharing This Article

Ankur Kumar Singh

I am a PHP programmer having some knowledge about Linux. I am always interested in web development and knowledge sharing. I am full time tech evangelist part time human being. :-)

Leave a comment/Ask Question

shares