O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Debugging WordPress with xDebug

You wouldn’t try and work out what’s wrong with your car engine by looking at the front bonnet.. so why debug your application from the outside when you can “pop the hood”?

The xDebug extension for PHP offers some amazing tools for developers to both understand and debug problems in their applications, but is frequently passed over as its benefits, setup, and configuration are poorly understood.

This talk aims to bring xDebug to the masses, discussing the setup of xDebug for a couple of local environments ( currently Local by FlyWheel, Laravel’s Homestead and Laravel’s Valet, though open to including more ‘WordPress’ environments like chassis ) and the configuration of your IDE ( VS Code / PHPStorm). Along with some demonstrations of how this method of working can help everyone take their development to the next level.

Presented by Alex Bishop @aj_adl

  • Entre para ver os comentários

  • Seja a primeira pessoa a gostar disto

Debugging WordPress with xDebug

  1. 1. Debugging WordPress With xDebug Alex James Bishop @aj-adl
  2. 2. Huge thanks to the Organisers and Sponsors!
  3. 3. Using xDebug to profile our code and pinpoint bottlenecks
  4. 4. Using xDebug to debug our (WordPress) applications
  5. 5. Using xDebug to help develop features
  6. 6. Delivering higher-quality data to you as the developer
  7. 7. The Land Before Time xDebug
  8. 8. Late May, the Year 2000…
  9. 9. 🎉🎉🎉🎉 🎉
  10. 10. V4.0 !!! Now with added programming language!
  11. 11. var_dump( $variable );
  12. 12. It’s been a little while since 2000…
  13. 13. var_dump( $variable );
  14. 14. • xDebug offers lots of utility • xDebug does take some time to setupvar_dump( $variable ); error_log( $variable );
  15. 15. Print based debugging
  16. 16. Echo / Print based debugging • Only gives us values for chosen variables • Doesn’t show us the rest of the current scope • Captures variables at single point in time
  17. 17. To use an analogy..
  18. 18. To use an analogy..
  19. 19. Step-through debugging • Stops the execution at a certain (break) point. • Ability to inspect all variables in current scope • See current call stack leading to breakpoint • Advance through the execution to see changes over time
  20. 20. Echo based debugging requires modifying your code..
  21. 21. $would_do = anything_for_love(); //var_dump( $would_do ); if ( $would_do === $that ){ //var_dump(“wont’t do that”); return false; }
  22. 22. Sometimes we can forget to remove them too…
  23. 23. https://xdebug.org/
  24. 24. xDebug can do a lot • Makes ‘var_dump’ better! • Code profiling to measure performance • Step-through debugging using DBGp protocol
  25. 25. Profiling with xDebug
  26. 26. Check out Otto’s talk at WC EU
  27. 27. xdebug.profile_output_dir Profiling: pro-tip for VM users
  28. 28. Remote debugging 💅🏼
  29. 29. Getting started • xDebug extension installed in our development environment • xDebug client (standalone or IDE) • Correct Configuration of both
  30. 30. Choose your Pokemon Local Development Environment
  31. 31. Choose your IDE
  32. 32. Bonus Tip: Browser Extensions!
  33. 33. Help with configuration
  34. 34. IDE Configuration
  35. 35. Config for both IDEs can be set at a global and per-project level
  36. 36. The remote debugging request flow
  37. 37. (or CLI )
  38. 38. xdebug.default_enable xdebug.remote_enable xdebug.remote_autostart ?XDEBUG_SESSIONS_START={id} XDEBUG_SESSION cookie
  39. 39. xdebug.remote_port xdebug.remote_host xdebug.remote_connect_back
  40. 40. DBGp request xdebug.remote_port=9000
  41. 41. Hello…. Is it DGBp you’re looking for?
  42. 42. DBGp request Breakpoints
  43. 43. Components of an xDebug Client
  44. 44. Call Stack
  45. 45. Variables
  46. 46. Watches
  47. 47. Console
  48. 48. Debugging Actions
  49. 49. The importance of state and timing
  50. 50. Pluging development examples • WooCommerce (core) & Extensions • Gravity Forms • View layers, MVC frameworks etc
  51. 51. Should I use xdebug?
  52. 52. if( $utility > $implementation ){ use_the_new_thing(); }
  53. 53. Detailed setup guides are on the way
  54. 54. Q & A
  55. 55. Thank You

×