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

Un vistazo a Xdebug

Pedro
October 10, 2013

Un vistazo a Xdebug

Charla en la reunión SymfonyVLC sobre Xdebug

Pedro

October 10, 2013
Tweet

More Decks by Pedro

Other Decks in Programming

Transcript

  1. Aviso a navegantes No soy un ninja del Xdebug... más

    bien alguien agradecido por lo que me ayuda :)
  2. ¿En qué nos puede ayudar Xdebug? • Información • Code

    Coverage • Function traces y profiling • Remote debugging pero antes...
  3. Configurar Xdebug En los *.ini que solamos usar: // /etc/php5

    /php.ini /conf.d/zzz_xdebug.ini /apache2/conf.d/zzz_xdebug.ini /cli/conf.d/zzz_debug.ini ... • Habilitamos xdebug • Máximo de recursión 100 • Deshabilitamos el operador @ xdebug.default_enable = 1 xdebug.max_nesting_level = 100 xdebug.scream = 1 Habilitamos el módulo: zend_extension=”/path/to/xdebug.so”
  4. Un vistazo a Xdebug • Información • Code Coverage •

    Function traces y profiling • Remote debugging
  5. Información General • xdebug_enable() • xdebug_disable() • xdebug_call_class() • xdebug_call_file()

    • xdebug_call_function() • xdebug_call_line() • xdebug_memory_usage() • xdebug_time_index() • xdebug_peak_memory_usage() • xdebug_start_error_collection() • xdebug_stop_error_collection() • xdebug_get_collected_errors() Funciones Parámetros • xdebug.default_enable • xdebug.max_nesting_level • xdebug.scream
  6. Información • xdebug.cli_color • xdebug.overload_var_dump • xdebug.var_display_max_children • xdebug.var_display_max_data •

    xdebug.var_display_max_depth • xdebug.dump.GET = * • xdebug.dump.SERVER = REMOTE_ADDR Variables Parámetros • var_dump() • xdebug_debug_zval() • xdebug_debug_zval_sdout() • xdebug_dump_superglobals() • xdebug_var_dump() Funciones
  7. Información • xdebug.collect_params • xdebug.dump_globals • xdebug.show_exception_trace • xdebug.show_local_vars Stack

    traces Parámetros • xdebug_get_declared_vars() • xdebug_get_function_stack() • xdebug_get_stack_depth() • xdebug_print_function_stack() Funciones
  8. Un vistazo a Xdebug • Información • Code Coverage •

    Function traces y profiling • Remote debugging
  9. Code coverage • xdebug.coverage_enable Parámetros • xdebug_start_code_coverage([options]) - XDEBUG_CC_UNUSED -

    XDEBUG_CC_DEAD_CODE • xdebug_stop_code_coverage() • xdebug_get_code_coverage() Funciones Genera un array donde nos indica las líneas de código que se han ejecutado (1), las que no (-1) o las que no tienen código ejecutable (-2) Visualuzación array ( ‘archivo.php’ => array( 1 => 1, 3 => 1, 4 => -1, ... ), ... )
  10. Un vistazo a Xdebug • Información • Code Coverage •

    Function traces y profiling • Remote debugging
  11. Function Traces y profiling • xdebug.auto_trace • xdebug.trace_enable_trigger • xdebug.trace_output_dir

    • xdebug.trace_output_name Function traces Parámetros Genera un archivo con toda la traza de ejecución de un script • vim (syntax file) • vdebug Visualización
  12. Function Traces y profiling Function traces Genera un archivo con

    toda la traza de ejecución de un script ¿Cómo activarlo? • activado automático • XDEBUG_TRACE: como parámetro o en la sesión • funciones: - xdebug_start_trace() - xdebug_stop_trace() XDebug helper
  13. Function Traces y profiling Pro!ile • xdebug.profiler_enable • xdebug.profiler_enable_trigger •

    xdebug.profiler_output_dir • xdebug.profiler_output_name Parámetros Genera un archivo con el pro!ile de la ejecución de un script • KCacheGrind • PhpStorm Visualización • XDEBUG_PROFILE ¿Cómo activarlo?
  14. Un vistazo a Xdebug • Información • Code Coverage •

    Function traces y profiling • Remote debugging
  15. • XDEBUG_SESSION ¿Cómo activarlo? Remote debugging Nos permite interactuar navegando

    por el código y obtener información a través de un cliente (normalmente un IDE) Parámetros • xdebug.remote_enable • xdebug.remote_handler • xdebug.remote_host • xdebug.remote_mode • xdebug.remote_port Cliente • configurar el puerto a escuchar (def. 9000) • configurar correspondencia con la ruta en el servidor (si remote_host no es 127.0.0.1) • establecer breakpoints