For advanced development a debugger may be very useful. A debugger will allow you to follow program execution and its effects, to observe the call stack of functions, and review the contents of variables at any point during execution.
Xdebug is the standard tool in PHP.
The main site:
Some articles on setting up and using it:
This Drupal module has additional tools for visualizing the Xdebug call traces:
For working in Drupal 8, you will need to add this line to the xdebug section of your php configuration, either in xdebug.ini or php.ini, if you are using a version of xdebug prior to 2.3:
I downloaded the php package from php.net at http://www.php.net/downloads.php#v5 For Mac 10.4 and 10.5 I have Xcode installed, which includes gcc and other necessary comilation-related packages.
To build xdebug.so I went to the directory (assuming you unpack the PHP source code archive in your home dir):
$ ./pecl install xdebug
this built xdebug.so and placed it in the direcrtory:
For the particular combination of MAMP + Komodo IDE
For my version of MAMP I copied xdebug.so to the following dir
(final dir name may vary by PHP version):
make sure Zend optimizer is OFF in MAMP preferences.
Make sure to restart apache after making these changes to php.ini. After verifying the location of xdebug.so, add the following to your php.ini file (or perhaps /etc/php5/conf.d/xdebug.ini, depending on your operating system):
you can add this to .htaccess in your Drupal root or a parent dir:
php_value xdebug.remote_enable on
These (among others) may also be useful to add to .htaccess if you want to profile
php_value xdebug.auto_trace On
php_value xdebug.show_mem_delta On
To debug in Komodo, make sure Debug >> Listen for Debug Connections is enabled. In Drupal, add the query string: ?XDEBUG_SESSION_START=1 .