How to enable Xdebug in WebMatrix

Xdebug is a very popular PHP extension that helps with debugging and profiling of PHP scripts by providing a lot of valuable debug information. Microsoft WebMatrix is a development tool for building web applications. When WebMatrix is used to build or modify a PHP-based web application the debugging tasks can be greatly simplified if Xdebug extension is used. This post explains how to install and use Xdebug extension with WebMatrix.

Step 1: Enable PHP in WebMatrix from the site “Settings” page:

Note that if you installed any of the PHP applications from the Application Gallery then PHP will be automatically enabled.

Step 2: Download the appropriate build of Xdebug extension from downloads page. If your site uses PHP 5.2 then download “5.2 VC6 Non-thread safe (32 bit)”. If your site uses PHP 5.3 then download “5.3 VC9 Non-thread safe (32 bit)”. Use 32 bit build even if your Windows OS is 64 bit.

Step 3: Install the extension by copying the downloaded file to the following locations:

  • For PHP 5.2 on Windows 64 bit:
    C:\Program Files (x86)\IIS Express\PHP\v5.2\ext\
  • For PHP 5.2 on Windows 32 bit:
    C:\Program Files\IIS Express\PHP\v5.2\ext\
  • For PHP 5.3 on Windows 64 bit:
    C:\Program Files (x86)\IIS Express\PHP\v5.3\ext\
  • For PHP 5.3 on Windows 32 bit:
    C:\Program Files\IIS Express\PHP\v5.3\ext\

Step 4: Open the php.ini file located in the PHP installation folder, e.g.
C:\Program Files\IIS Express\PHP\v5.2\php.ini and append the following at the end (make sure that the absolute path is correct for your version of PHP and Windows.):

zend_extension = C:\Program Files\iis express\PHP\v5.2\ext\php_xdebug-2.1.0-5.2-vc6-nts.dll

Step 5: Configure PHP to display errors by changing these PHP settings in php.ini file:

display_errors = On
error_reporting = E_ALL & ~E_NOTICE

Step 6: Test that extension is enabled and works by either calling a phpinfo() function from a script or by running a buggy script:

The Xdebug extension provides a lot of useful features that help with debugging of PHP applications. You can learn more about them from the Xdebug documentation. For example you can use it to profile a PHP application. Just change the php.ini file as shown below and then make a request to a PHP script:

zend_extension = C:\Program Files\iis express\PHP\v5.2\ext\php_xdebug-2.1.0-5.2-vc6-nts.dll
xdebug.profiler_enable = On
xdebug.profiler_output_dir = C:\Windows\temp

The profile log will be saved into the specified directory and will have a name cachegrind.out.* Use WinCacheGrind to open and analyze it:


ruslany on February 18th 2011 in PHP

PoorFairAverageGoodExcellent (No Ratings Yet)

7 Responses to “How to enable Xdebug in WebMatrix”

  1. Gravatar ImageKregg responded on 22 Feb 2011 at 5:39 pm #

    If you’re not sure which DLL to use(thread safe vs non), go to this page:

    Provide the info required. Personally, I do a commandline php -i > C:\phpinfo.txt

    And then copy that info.

  2. Gravatar ImageJoseph responded on 06 Sep 2011 at 3:10 pm #

    My error messages were not formatted nicely like yours. In order to get it working I turned html_errors On in my php.ini

    html_errors = On

  3. Gravatar ImageNeil S responded on 08 Jan 2012 at 1:50 am #

    If one is using a more recent version of WebMatrix / PHP, you want to download the VC9 version of xdebug, not VC6. The phpinfo page showed me that xdebug was not running, but it didn’t say why. Only when I opened a command prompt, navigated to the Program files directory with php.exe in it, and then ran php.exe -m, did it reveal that xdebug could not be run because the compiler version was wrong.

  4. Gravatar Imagekristina responded on 03 Sep 2012 at 4:53 am #

    Hello Ruslany,

    I have point-out your trick to Webmatrix on their uservoice site but it’s not any good response.

    Do you have any idea if they will made it available for people to enable by default or have a option to get it easily.


  5. Gravatar ImageJohn responded on 28 Feb 2013 at 1:22 pm #

    Thanks for posting this. These instructions work for PHP 5.3 but I was unable to get them to work for PHP 5.4

  6. Gravatar Imageburak responded on 08 Mar 2014 at 9:54 am #

    is it possible to put breakpoint in php code in webmatrix? how? thanks.

  7. Gravatar ImageStas responded on 15 May 2015 at 12:30 am #

    I prefer to use Codelobster to debug PHP code

Trackback URI | Comments RSS

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

XML Markup: If You want to add XML code to the comment please XML encode it first, otherwise the code will not show up.

Recently Published Articles