php and js debugging

12

Click here to load reader

Upload: stefan-nistor

Post on 08-May-2015

1.280 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Php and js debugging

PHP and JS debuggingby Andrei Perciun

Page 2: Php and js debugging

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

Page 3: Php and js debugging

PHP/Drupal debugging techniques

Page 4: Php and js debugging

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/

Page 5: Php and js debugging

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

Page 6: Php and js debugging

● http://xdebug.org/● Configuration - http://xdebug.org/wizard.php● xdebug.remote_enable=On● xdebug.profiler_enable=On

XDebug

Page 7: Php and js debugging

● http://static.zend.com/topics/Zend-Debugger-Installation-Guide.pdf

● http://www.zend.com/en/products/server-ce/● Evaluate expressions

Zend Debugger

Page 8: Php and js debugging

Javascript debugging techniques

Page 9: Php and js debugging

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

Page 10: Php and js debugging

What else?

Page 11: Php and js debugging

● XDebug profiler● Zend Profiler● XHProf● PHP Profiler● New Relic (Pantheon & Acquia use it)

Profiling

Page 12: Php and js debugging

Thank [email protected]