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
- Go to Xdebug Download Page and choose your appropriate binary for your xampp installation.
- Copy the downloaded DLL file into your XAMPP php extension directory. For my case it is at C:\xampp\php\ext directory.
- Now open your PHP.ini file and add the below configuration. For me PHP.ini file is at c:\xampp\php\php.ini
xdebug.remote_autostart = 1
- 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
- Download xdebug suitable version of xdebug from xdebug.org website. I have downloaded xdebug-2.4.0
- 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.
- Go to the extracted folder by hitting command cd xdebug-2-4-0 command.
- 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
- 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
- Run the make command on the command terminal. Just type make and hit enter.
- 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.
- 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
- Almost you are done. Open your PHP.ini file and put below configuration for basic xdebug enablement:
xdebug.remote_autostart = 1
- 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:
Troubleshouting of xdebug on XAMPP MAC OSX
Below are some of the issue you will face while installing Xdebug for XAMPP on mac.
- 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.
- 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.