The most common way of debugging a PHP application is to use some functions such as
echo
,
die()
,
var_dump()
,and print_r()
. In Magento, you can use the Mage::log()
statement to print some logs to a file, but this isn't a real debugger.
With a real debugger, you can break the script and look at the variables and values they have. You can also change values, go further, skip statements, and more.
In PHP, you can configure Xdebug to debug your PHP script or application. In this recipe, we will see how to install Xdebug in the development environment and how we can integrate it with an IDE.
In this recipe, we will start an Xdebug session with the NetBeans IDE. Open NetBeans and set the Magento project as Main Project. Make sure all the URLs are configured correctly in the Property settings of the project.