php and js debugging
TRANSCRIPT
PHP and JS debuggingby Andrei Perciun
What is debugging?
Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected*
** http://en.wikipedia.org/wiki/Debugging
PHP/Drupal debugging techniques
PHP/system configuration (php.ini)○ display_errors = On ○ log_errors = On○ error_log=”php-errors.log”○ error_reporting = E_ALL & ~E_NOTICE○ syslog/Event viewer
Print steps, variables, statements...○ print/echo, print_r(), var_dump(), die()/exit()○ debug_backtrace(), debug_print_backtrace()○ Drupal - dpm(), drupal_set_message(), watchdog()
Debuggers○ XDebug *○ Zend Debugger **
PHP debugging techniques
* http://xdebug.org/** http://www.zend.com/en/products/server-ce/
Core functions○ drupal_set_message()○ watchdog() - watchdog('my_module', print_r($arr,
TRUE));Devel
○ dpm()○ dvm()○ devel_render() - array element to the screen○ db_queryd() - Drupal 6 only○ dpq() - Drupal 7 only○ views_debug()/vpr()○ devel/php, devel/reinstall
Drupal debugging functions
● http://xdebug.org/● Configuration - http://xdebug.org/wizard.php● xdebug.remote_enable=On● xdebug.profiler_enable=On
XDebug
● http://static.zend.com/topics/Zend-Debugger-Installation-Guide.pdf
● http://www.zend.com/en/products/server-ce/● Evaluate expressions
Zend Debugger
Javascript debugging techniques
System configuration○ IE - Disable script debugging, Display notification
about every script error, Show Friendly HTTP errors○ Other
Print steps, variables, statements, network logs○ alert()○ console.log()○ window.status
Debuggers○ Firefox and Chrome - Firebug, plus default tools○ IE - Developer tools○ Opera - Dragonfly
JS debugging techniques
What else?
● XDebug profiler● Zend Profiler● XHProf● PHP Profiler● New Relic (Pantheon & Acquia use it)
Profiling
Thank [email protected]