Enable Xdebug on XAMPP for Windows

XAMPP is a free and open source cross-platform web server stack that offers Apache (Web Server), MySQL (Relational Database) and interpreters for PHP and Perl programming languages. XAMPP is one of the most feature rich Web Server stack solution.

XAMPP is great for developing a website or web application locally. XAMPP by default is set in PHP development mode, which means you don’t have to configure it if you are using it for development purpose. You have the complete freedom right from the installation process to customize and tailor XAMPP to your preference.

XDebug is a PHP extension which provides debugging and profiling capabilities. It uses the DBGp debugging protocol. The debug information that XDebug can provide includes the following:

  • stack and function traces in error messages with:
    • full parameter display for user defined functions
    • function name, file name and line indications
    • support for member functions
  • memory allocation
  • protection for infinite recursions
  • profiling information for PHP scripts
  • code coverages analysis
  • capabilities to debug your scripts interactively with a debugger front-end

Setting up XDebug.

Open your XAMPP panel and click the Config button, a menu will appear.

Click the fourth option in the menu that says PHP (php.ini).

This should open the ‘php.ini’ file in notepad or your default text editor.

Now add the following code block at the end of your php.ini file.

[XDebug]
xdebug.remote_enable =on
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_output_dir="\xampp\tmp"
[PHP_XDEBUG]
zend_extension="C:\XAMPP\php\ext\php_xdebug.dll"

Code language: TOML, also INI (ini)

Now you can restart Apache, After Apache restarts you will see Xdebug in action.

Enjoy. Happy Coding!