Using the Debugger

Important Links

The first link is the bookmarklet generator for PhpStorm. The IDE key is CNM-DEBUG. The second link is the official documentation for setting up the PhpStorm debugger.

Debugging From Home: Firewall Configuration

The debugging process requires the web server to make a direct connection to your laptop. This will work without any additional effort on any CNM campus. However, debugging from home requires a few additional steps:

  1. Go to http://test-ipv6.com/ and test your laptop.
  2. If the the IPv6 score === 0, forward port 9000 to your laptop. This process varies based on your router. Consult your router's documentation or try the resources at PortForward.com.
  3. If the the IPv6 score > 0, port forwarding is not necessary. Proceed to the next step.
  4. Ensure your firewall is not blocking the debugger connection. On the Microsoft Windows firewall, this may be a matter of configuring the network you're on as a Home or Work network instead of a Public network.

Once these steps are complete, the debugger should work from home.

Example Code

<?php
/**
 * adds two numbers and returns the result
 *
 * @param double $firstNumber first addend
 * @param double $secondNumber second addend
 * @return double sum of the two numbers
 * @throws UnexpectedValueException if the addends aren't numeric
 **/
function addTwoNumbers($firstNumber, $secondNumber) {
	// verify the addends are numeric
	$firstNumber = filter_var($firstNumber, FILTER_VALIDATE_FLOAT);
	$secondNumber = filter_var($secondNumber, FILTER_VALIDATE_FLOAT);
	if($firstNumber === false || $secondNumber === false) {
		throw(new UnexpectedValueException("addends are not numeric"));
	}

	// return the sum
	$sum = $firstNumber * $secondNumber;
	return($sum);
}

echo "2.1 + 3.2 = " . addTwoNumbers(2.1, 3.2);