Click here to Skip to main content
15,887,333 members
Articles / Web Development / HTML
Tip/Trick

Debugging PHP on Windows

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
12 Feb 2019CPOL2 min read 10.9K   2  
How to debug PHP on Windows

Introduction

If you are developing PHP using PHPStorm and IIS and need to debug it, here is what to do. PHP, IIS, PHPStorm should already be installed and configured. This is a short tutorial and I wrote it as there is none available on the net, that is:

  1. short,
  2. for windows developers, and
  3. complete

Step 1: Installing xDebug Extension

Download the xDebug extension for PHP from https://xdebug.org/download.php. Choose the version that is the same as the PHP version you are using.

GO to your PHP.ini and insert the following lines at the bottom of the ini file:

PHP
[XDebug]
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0
xdebug.profiler_output_dir="C:\tmp"

Search for the extension= entries and add:

zend_extension="C:\PHP5.6\ext\php_xdebug.dll"

Set the correct path for profile_output_dir (some temp path) and zend_Extension (the full path to the extension).

Step 2: Install the xDebug Browser Extension

Open the HTML browser you are using and install the xDebug add on.

For Firefox and Chrome, I'm using: XDebug Helper by Brain Gilbert.

After that, go to the Options of the extension and set its "IDEKey" to "PHPStorm".

Step 3: Configure IIS

Open IIS, choose your sever, go to Fast CGI Settings, double click it, double click on the PHP version you have configured. Now go to "Processmodel" and search for Activity timeout and Request timeout. Set it to something useful. I set it to 600, so you will have 10 minutes for debugging. If you do not make this setting, then you will timeout after 60 seconds.

Step 4: Connect with PHPStorm

Open PHPStorm. Open the Page you want to debug in your configured browser. In PHPStorm, click listen for PHP Debug connections Tool Button (it looks like a telephone handle). In Browser, start xDebug in Debug Mode. Now in PHPStorm, a message shows up to accept the incoming from xDebug connection. Confirm it.
If it does not come up, maybe PHPStorm is misconfigured. In its default settings, it should work flawlessly.

:-D Now you are done. Happy debugging!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Germany Germany
20 Years professional development experience!
Fullstack developer, cross platform developer, REST Expert.
I can develop anything as I have. But I h@te driver development.

Have a nice day Big Grin | :-D

Comments and Discussions

 
-- There are no messages in this forum --