Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Power Debugging & Profiling Your PHP Apps

Power Debugging & Profiling Your PHP Apps

Abu Ashraf Masnun

January 12, 2023
Tweet

More Decks by Abu Ashraf Masnun

Other Decks in Programming

Transcript

  1. Error  Display   •  Turn  on  error  display    

    •  Report  all  errors   •  E_ALL  |  E_STRICT   •  Don’t  ignore  those  “NoKce”  messages  
  2. Print  &  Die   •  Output  something  and  then  terminate

     the   script.     •  var_dump()     •  print_r()   •  Output  buffering  for  cleaner  output   •  debug_backtrace()  
  3. Logging   •  Use  a  logging  library  (Monolog,  anyone?)  

    •  error_log()   •  mod_php  sets  stderr  to  apache  logs:   –  file_put_contents('php://stderr',  print_r($foo,  TRUE))   •  trigger_error()  &  set_error_handler()   Tail  your  logs:     tail  -­‐f  your_log_file_path