Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Methods of debugging -


Published on

This is a presentation compiled by Mihai Gutuleac, on the topic of "Debugging methods". It presents a list of useful and handy tools and error handler frameworks which will help web developers to easily find out and debug the errors and also to handle more appropriate the raised exceptions in their web applications.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Methods of debugging -

  1. 1. Methods of debugging
  2. 2. Exceptions $exception = new Exception("Error message",1); $exception->getCode(); $exception->getMessage(); throw $exception;
  3. 3. Exceptions • try{ throw new Exception('Exception'); } catch (Exception $e){ //... } catch (OutOfBoundsException $e){ //... } finally { // finally only for > PHP 5.5 }
  4. 4. Exception Handlers set_exception_handler('exception_handler'); function exception_handler(Exception $e){ // This method will be called for every uncaught exception } // Used after changing the exception handler, to revert to the previous one restore_exception_handler();
  5. 5. Error Handler set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) { // error });
  6. 6. PHP INI CONF DEVELOPMENT // Display errors display_startup_errors = On display_errors = On //Report all errors error_reporting = -1 //Turn on error logging log_errors = On PRODUCTION // Do not display errors display_startup_errors = Off display_errors = Off // Report all errors BUT NO notices error_reporting = E_ALL & ~E_NOTICE //Log Errors log_errors = On
  8. 8. var_dump($jsonDecodedObj) object(stdClass)#117 (1) { ["glossary"]=> object(stdClass)#118 (2) { ["title"]=> string(16) "example glossary" ["GlossDiv"]=> object(stdClass)#119 (2) { ["title"]=> string(1) "S" ["GlossList"]=> object(stdClass)#120 (1) { ["GlossEntry"]=> object(stdClass)#121 (7) { ["ID"]=> string(4) "SGML" ["SortAs"]=> string(4) "SGML" ["GlossTerm"]=> string(36) "Standard Generalized Markup Language" ["Acronym"]=> string(4) "SGML" ["Abbrev"]=> string(13) "ISO 8879:1986" ["GlossDef"]=> object(stdClass)#122 (2) { ["para"]=> string(72) "A meta-markup language, used to create markup languages such as DocBook." ["GlossSeeAlso"]=> array(2) { [0]=> string(3) "GML" [1]=> string(3) "XML" } } ["GlossSee"]=> string(6) "markup" } } } } }
  9. 9. Kint::dump($jsonDecodedObj)
  10. 10. PHP Debug Bar
  11. 11. Laravel Debugbar (Integrates PHP Debug Bar)
  12. 12. XDebug
  13. 13. Rubber duck debugging
  14. 14. • Rubber duck debugging is an informal term used in software engineering for a method of debugging code. The name is a reference to a story in a book in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line-by-line, to the duck. Many other terms exist for this technique, often involving different inanimate objects. • Many programmers have had the experience of explaining a programming problem to someone else, possibly even to someone who knows nothing about programming, and then hitting upon the solution in the process of explaining the problem. source: