If you are a PHP programmer and are using XAMPP on Mac, installing XDebug will help you debug code more effectively and save a lot of time. In this article, Tech Tip Zone will guide you step by step to install XDebug for XAMPP on macOS. Specifically, in this tutorial, Tech Tip Zone will use Macbook Pro M1.
What is XDebug?
XDebug is a PHP extension that allows you to monitor and debug your code. With XDebug, you can view variables, callback stacks, and even perform code inspections in real time. This tool is extremely useful when you develop complex applications. In fact, coders spend more time debugging than coding.
How to Install XDebug for XAMPP on macOS
Method 1: Download the Xdebug library file via the homepage
Note:Currently, TechTipzone can no longer find the .SO file, so if you still see it, go to thephp.ini configurationstep, otherwise followmethod 2.
Step 1: Download Corresponding PHP Version
First, you need to check the PHP version that XAMPP is using. You can check by opening Terminal and running the following command:
php -v

Once you have your PHP version information, go to the official XDebug website atXDebug Downloadsto download the version that matches your PHP. Note that you need to choose the correct version that matches your XAMPP architecture.
Step 2: Unzip and Copy the XDebug File
Once downloaded, you will have a .dll (Windows) or .so (macOS) file. For macOS, you will need to copy that file into the XAMPP extension folder. Typically, the XAMPP folder will look like this:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-xxxxxx/
Just replace ‘xxxxxx’ with the actual hash in your folder. Proceed to copy the XDebug file you just downloaded into this folder.
Method 2: Install Xdebug for xampp on mac m1 via PECL and Homebrew
Step 1:Install homebrew if your macOS doesn’t have homebrew yet by opening terminal and following these steps.
/bin/bash -c"$(curl -fsSL //raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2:Install Autoconf
brew install autoconf
Step 3:Install PECL
brew install pecl
Step 4:Install XDebug – Actually it is building for you a .SO library file of xdebug
pecl install xdebug
After completing the above 3 steps, enter the following command to see where the .SO library file is located using the command
php -i | grep extension_dir
This command will show the path of the SO file. Next, go to the php.ini file configuration section.
Update php.ini File
Next, you need to configure XDebug to work. First, open the php.ini file of XAMPP. This file is usually located at:
/Applications/XAMPP/xamppfiles/etc/php.ini
Open the php.ini file with a text editor (like TextEdit or Visual Studio Code) and add the following code to the end of the file:
zend_extension="/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-xxxxxx/xdebug.so"
Replace ‘xxxxxx’ with the corresponding hash you found earlier. You should also add some basic settings to determine how XDebug will behave:
[xdebug]
zend_extension="/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so"
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_port=9003

Restart XAMPP
Once you have updated the php.ini file, you will need to restart your XAMPP server for the changes to take effect. To do this, open the XAMPP Control Panel and select ‘Stop’ and then ‘Start’ Apache again.
Check Settings
To make sure that XDebug has been installed successfully, you can create a PHP file to test. Create ainfo.php
new file in the htdocs folder of XAMPP with the following content:
<?php
phpinfo();
?>
Go to localhost/info.php in your browser. If you see information about XDebug on this page, the installation was successful.

IDE Configuration
The final step is to configure your IDE to use XDebug. If you are using a popular IDE like Visual Studio Code, you will need to set up your server and debugging configurations. Most of these IDEs have a console where you can easily set up debugging with XDebug.
For PhpStorm:
- Go to
Preferences
>Languages & Frameworks
>PHP
>Debug
. - Make sure the port
9003
is in use. - Set up a new server under
PHP
>Servers
to adjust the server address correctly.
For Visual Studio Code:
- Go toVisual Studio Code -> Extension -> “PHP Debug”
- InstallExtension
- Click “Run and Debug”
Instructions for installing XDebug for XAMPP on mac
If you have not installed xampp, you can refer to the article:Instructions for installing XAMPP on Macbook M1
Conclude
Installing XDebug for XAMPP on macOSis not as difficult as you think. With instructions from Tech Tip Zone, you can do it easily and effectively. XDebug not only helps you detect errors quickly but also helps you optimize code more easily.
If you want to explore more macOS tips, visit theTech Tip Zonewebsite . We look forward to providing you with lots of useful information to improve your programming skills!