Firstly, you should have to download a wamp server from WAMP website, http://www.wampserver.com/en/. Choose one which suits your computer os. I chose wamp server 64 bit(x64) 3.0.6. Click the URL and it will take you to sourceforge.net. Install wamp server, follow the default configuration and finish. When you finished installed WAMP. Open a web browser to test. Type localhost on the URL of your web browser. If you can get the page like this, Well done!
Secondly, download NetBeans. Go to Netbeans download web page. https://netbeans.org/downloads/. Choose the right version which can support PHP or all of the developing language. I chose all. It could take quite a while to install it. Same way like WAMP, choose default configuration.
Then, download xDebug. Luckily, xDebug has a wizard to tell us which version we should use depending on our different configuration. Type localhost in your web browser, click phpinfo(). You will get a webpage like this. Use ctrl+A to copy all this
web page into a clipboard. And then paste this information into the areatext on the web page https://xdebug.org/wizard.php. And then click the button
Follow the instructions, download and copy to the right folder, update the php.ini and restart the WAMP server. Open the localhost and click the phpinfo() again. You should see the xDebug information like this.
Understand the IDE Key, it is useful when you config the Netbeans. Open the php.ini of your WAMP server. Make sure you have these sentences.
[xdebug]
zend_extension ="c:/wamp64/bin/php/php5.6.25/zend_ext/php_xdebug-2.4.1-5.6-vc11-x86_64.dll"
;xdebug.remote_enable = off
xdebug.remote_enable = 1
xdebug.remote_host = 127.0.0.1
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
xdebug.remote_handler = dbgp
xdebug.idekey = "netbeans-xdebug"
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0
xdebug.remote_enable should be 1 or true or on.
xdebug.remote_host can be 127.0.0.1 or localhost
xdebug.remote_port should be the same with your NetBeans configuration, the default value of the NetBeans is 9000
xdebug.idekey should be the same with your NetBeans configuration.
Click Netbeans Tools->Options->Debugging . Make sure the Debugger Port, Session ID are the same with the value in your php.ini file. Choose "Stop at First Line" because it will definitely debug into your file even you didn't set any breakpoints.
Save all the configuration. Restart WAMP and NetBeans. Create a new PHP project named phpXDebug. And copy the file below to the index.php.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>NetBeans PHP debugging sample</title>
</head>
<body>
<?php
$m=5;
$n=10;
$sum_of_factorials = calculate_sum_of_factorials ($m, $n);
echo "The sum of factorials of the entered integers is " . $sum_of_factorials;
function calculate_sum_of_factorials ($argument1, $argument2) {
$factorial1 = calculate_factorial ($argument1);
$factorial2 = calculate_factorial ($argument2);
$result = calculate_sum ($factorial1, $factorial2);
return $result;
}
function calculate_factorial ($argument) {
$factorial_result = 1;
for ($i=1; $i<=$argument; $i++) {
$factorial_result = $factorial_result*$i;
}
return $factorial_result;
}
function calculate_sum ($argument1, $argument2) {
return $argument1 + $argument2;
}
?>
</body>
</html>
Now, everything is fine. Debug the file of index.php. If you can see the web page like this, congratuation!
Any questions? You may check the Netbeans community. http://wiki.netbeans.org/HowToConfigureXDebug#How_to_configure_XDebug
Thanks for reading!Enjoy coding. Enjog debugging!