O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Drupal Auckland Meetup; Debug like a pro

While seeking another PHP developer and during the interview process, I was blown away by how few know how to debug complex problems.

So this time the subject matter is debugging.
I'll cover several debugging strategies and debug methods.

So if you are still using print_r(), var_dump(), debug_backtrace(), dump(), drupal_set_message(), error_log(), watchdog(), die, exit or the devel module then this talk is for you.

  • Entre para ver os comentários

  • Seja a primeira pessoa a gostar disto

Drupal Auckland Meetup; Debug like a pro

  1. 1. WHY I’M DOINGTHISTALK • While interviewing developers, I was blown away by how few know how to debug complex problems.  • Many failed to explain how you go about debugging. • Only a few debug strategies were mentioned.
  2. 2. WHAT WILL I COVER • old school way • xdebug • profiler • devel module • kCachegrind • query logging • tailing logs
  3. 3. BEFORE LOOKING CODE
  4. 4. THE BUSINESS CASE? • First truely understand the problem. • Verify there is a problem. • How critical is it? Maybe a simple messaging is enough. • Can you reproduce the problem. • Do you have first hand project knowledge. • If there are tests are they passing?
  5. 5. OLD SCHOOL • print_r() • var_dump() • debug_backtrace() • mail() • drupal_set_message() • form_set_error() • devel module
  6. 6. JUST DON’T! • You are editing code. • You might accidentally break something. • It might not give you the full picture. (print_r, devel) • If you made lots of edit you’ll forget to remove it. • Somethings the behaviour is not what you expect.
  7. 7. DEMO • Drupal 7 form submit $form_state not showing print_r() • Drupal 8 form submit $form_state memory overrun
  8. 8. XDEBUG FEATURES • Better error reporting • Shows stack trace • Variable inspection • Step by step code execution • Step in and Step out functionality • Contains a profiler
  9. 9. INSTALL & CONFIGURE • brew install php71-xdebug • Install debug helper (chrome / firefox, / safari) • Edit php.ini or debug.ini xdebug.max_nesting_level = 256 xdebug.remote_autostart = 0 xdebug.remote_enable = 1 xdebug.remote_port = 9000 xdebug.remote_host = localhost
  10. 10. DEMO XDEBUG • Variable inspection in form submit for $form_state • Step in and Step out functionality • Conditional breakpoints • Show stack trace
  11. 11. INSTALL & PROFILER • brew install php71-xdebug • brew install qcachegrind • brew install graphviz • Install debug helper (chrome / firefox, / safari) • Edit php.ini or debug.ini xdebug.profiler_enable = 0 xdebug.profiler_enable_trigger = 1 xdebug.profiler_output_name = cachegrind.out-%H-%R xdebug.profiler_output_dir = /Users/garethhall/xdebug/profiler/
  12. 12. DEMO PROFILER
  13. 13. QUERY LOGGING
  14. 14. SETUP • Edit my.cfn [mysqld] max_allowed_packet = 300M innodb_lock_wait_timeout = 120 general-log = 1 general-log-file=/Users/garethhall/query.log
  15. 15. QUESTIONS

×