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.
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
Drupal Auckland Meetup; Debug like a pro
1.
2. 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.
3. WHAT WILL I COVER
• old school way
• xdebug
• profiler
• devel module
• kCachegrind
• query logging
• tailing logs
5. 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?
6. OLD SCHOOL
• print_r()
• var_dump()
• debug_backtrace()
• mail()
• drupal_set_message()
• form_set_error()
• devel module
7. 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.
8. DEMO
• Drupal 7 form submit $form_state not showing print_r()
• Drupal 8 form submit $form_state memory overrun
9.
10. XDEBUG FEATURES
• Better error reporting
• Shows stack trace
• Variable inspection
• Step by step code execution
• Step in and Step out functionality
• Contains a profiler