Xdebug / debugging PHP applications (WebElement #2)

Xdebug / debugging PHP applications (WebElement #2)

1633975316e340c5f24414567a3f3679?s=128

Vladimír Kriška

December 08, 2011
Tweet

Transcript

  1. Xdebug debugging PHP applications WebElement event #2, 08.12.2011 Vladimír Kriška,

    @ujovlado
  2. “I Don't Need A Debugger” • Chuck Norris doesn't •

    for everyone else is Xdebug These functions are insufficient: • echo • print_r() • var_dump() … or your's framework built-in functions And you probably use them with <pre> tag.
  3. Xdebug • Open Source debugging tool https://github.com/derickr/xdebug • Easy to

    configure • Easy to use • Works on every platform • Nice, colored output
  4. Initial configuration • html_errors = On • zend_extension=/path/to/xdebug.so e.g.: /usr/lib/php5/20090626/xdebug.so

  5. Let's start How much to show: • xdebug.var_display_max_children (128) •

    xdebug.var_display_max_data (512) • xdebug.var_display_max_depth (3) Xdebug overloads var_dump() by default.
  6. Example code

  7. Output

  8. Stack trace - code

  9. Stack trace - output

  10. Function trace - code

  11. Function trace - output file

  12. Code coverage Detect which lines of script was executed. Three

    functions: • xdebug_start_code_coverage() • xdebug_stop_code_coverage() • xdebug_get_code_coverage()
  13. Code coverage - code

  14. Code coverage - output

  15. Tracefile analyser Set xdebug.trace_format=1 tracefile-analyser.php tracefile.xt [sortkey] [elements] Available sortkeys:

    • calls • time-inclusive • memory-inclusive • time-own • memory-own
  16. None
  17. Profiling Set: xdebug.profiler_enable=1 xdebug.profiler_output_dir=/var/www/xdebug/tmp Generates cachegrind file. Tools: • KCachegrind

    • Webgrind
  18. Debugging xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000

  19. “Scream” mode xdebug.scream=1 Set this to disable the “@” operator.

    All errors, warnings and notices will be visible.
  20. Some new features in 2.2 xdebug.cli_color - colored output in

    CLI mode xdebug.coverage_enable - if you turn this off, it speeds up Xdebug, but coverage analysis won't work
  21. Resources Xdebug home page - http://xdebug.org/ Derick Rethans - http://derickrethans.nl/

  22. Thank you! Any questions?