Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Getting Started With Xdebug

461 visualizaciones

Publicado el

Presented at Pacific Northwest PHP 2015, in the UnCon track.

Publicado en: Tecnología
  • Sé el primero en comentar

Getting Started With Xdebug

  1. 1. Jeremy Ward Pacific Northwest PHP Conference September 12, 2015 Getting Started With Xdebug
  2. 2. • Developer at Westwerk • Drummer for Loud Nerves • Board game geek • Fan of stand-up comedy About Me
  3. 3. • About ‘Debugging’ • Xdebug: Overview, Features, and Benefits • Xdebug Installation and Setup • Application Debugging and Profiling Today’s Topics
  4. 4. Our Goal
  5. 5. Understanding Debugging and Context
  6. 6. Evaluating, understanding, and validating how your application works. What is ‘debugging’?
  7. 7. var_dump()
  8. 8. Context Matters
  9. 9. Xdebug Overview
  10. 10. • PHP extension that provides debugging and profiling capabilities • Developed by Derick Rethans • First released in May 2002 • Uses the DBGp debugging protocol What is Xdebug?
  11. 11. • Debugging support • Stack trace view • Profiling • Code coverage analysis • Function logging Features
  12. 12. • Step through code operations line-by-line • View application data in memory at pre-determined breakpoints • Access function call stack • Update variable values during runtime • More detailed error messaging Benefits
  13. 13. • Xdebug support exists in over a dozen IDES, including: • PhpStorm • Eclipse • NetBeans • Plain text editors too (with extensions)! • VIM • Sublime Text • Notepad++ Editor Support
  14. 14. Setup and Configuration
  15. 15. Assumptions
  16. 16. • Pre-installed w/ some environments (MAMP, XAMPP, Vagrant) • Install from source • PEAR/PECL • Detailed instructions at http://xdebug.org/docs/install Installation
  17. 17. • Locate php.ini file for your PHP installation • Unsure? Check ‘Loaded Configuration File’ using phpinfo() • Basic settings needed to enable remote debugging: • zend_extension=“/path/to/your/xdebug/extension” • xdebug.remote_enable=1 • xdebug.remote_host=localhost • xdebug.remote_port=9000 • xdebug.remote_autostart=1 Configuration
  18. 18. • Used primarily in virtual environments such as Vagrant • Helps the server layer find the location of local files • PhpStorm (and presumably other IDEs) include wizards for setting this up Path Mappings
  19. 19. Using Xdebug
  20. 20. • Add query parameters to the script you’re trying to load: • Start: [url]?XDEBUG_SESSION_START=[session_name] • Stop: [url]?XDEBUG_SESSION_STOP=[session_name] Enabling/Disabling Xdebug
  21. 21. • PhpStorm’s website has a list of recommended browser extensions:
 https://confluence.jetbrains.com/display/PhpStorm/Browser+Debugging +Extensions • Chrome: • Xdebug Helper • Xdebug Enabler • Firefox: • easy Xdebug • The Easiest Xdebug • Safari: • Xdebug Toogler Browser Extensions
  22. 22. • var_dump() - stylized! • xdebug_break() - pauses the app as if a breakpoint was set • xdebug_get_declared_vars() - returns array of elements defined in the current scope. • Complete list: http://xdebug.org/docs/all_functions Useful functions
  23. 23. • Profiling • KCacheGrind (Linux) • Webgrind: https://github.com/jokkedk/webgrind • Debugging • MacGDBp (OSX) • Aforementioned browser extensions Tools
  24. 24. Demo
  25. 25. • Xdebug website: http://xdebug.org • Xdebug and You: Why You Should Be Using a Real Debugger (Juan Treminio) https://jtreminio.com/2012/07/xdebug-and- you-why-you-should-be-using-a-real-debugger/ • Debugging and Profiling PHP with Xdebug (Shameer C) http://www.sitepoint.com/debugging-and-profiling-php- with-xdebug/ Additional Resources
  26. 26. Thank You! Feedback http://joind.in/15183 Questions? Email: jeremy@jmichaelward.com Twitter: @_jmichaelward IRC: jmichaelward

×