The Art of Debugging @ Phpro Weekend 05/17

The Art of Debugging @ Phpro Weekend 05/17

6c18f9874bd8dd408e41d77518987a0e?s=128

Toon Verwerft

May 19, 2017
Tweet

Transcript

  1. None
  2. None
  3. None
  4. Can  be  very  big Can  be  spread  across  many  files

    Can  be  spread  across  multiple  devices
  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. DBGP  Server:  9000 IDE  Key:  $_COOKIE,$_GET Breakpoints Remote  IP Remote

     Port IDE  Key
  13. DBGP  Server:  9000 export  XDEBUG_CONFIG="idekey=X" Breakpoints Remote  IP Remote  Port

    IDE  Key
  14. None
  15. None
  16. XDebug Function  Trace

  17. LLDB  /  GDB

  18. Strace /  dtruss

  19. None
  20. None
  21. None
  22. None
  23. 1. Check  log  files 2. Try  to  reproduce  the  bug

    3. Go  through  the  code  step-­‐by-­‐step 4. Add  breakpoint  at  important  locations
  24. None
  25. KNOW  THE  DOMAIN

  26. SINGLE  RESPONSIBILITY • One  class  has  one  responsibility • Use

     controllers  to  transform  the  request  in  a  response • Use  services  to  handle  business  logic • Use  data  managers  to  collect  /  store  data • Use  Events  to  trigger  side  actions • Use  validators  for  validation
  27. DEFENSIVE  PROGRAMMING • Enable  strict  types • Specify  all  argument

     types • Specify  return  type • Validate  state • Don't  be  afraid  to  throw  exceptions • Always  keep  track  of  the  unhappy  path
  28. CODE  CALISTENICS 1. Only  one  indentation  per  method 2. Do

     NOT  use  the  "else"  keyword 3. Wrap  all  primitive  types  if  it  has  behavior 4. Only  one  -­‐>  per  line 5. Do  not  abbreviate 6. Keep  your  classes  small 7. Limit  the  number  of  instance  variables 8. Use  first  class  collections
  29. None
  30. None
  31. PHP  Inspections  EA  extended PHP  Annotations Symfony  Plugin Magicento Drupal

     Plugin IDE  CONFIGURATION
  32. AUTOMATED  TESTING PHP-­‐CS LINTERS

  33. CODE  REVIEWS

  34. None