SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
Jeremy Ward
Pacific Northwest PHP Conference
September 12, 2015
Getting Started With Xdebug
• Developer at Westwerk
• Drummer for Loud Nerves
• Board game geek
• Fan of stand-up comedy
About Me
• About ‘Debugging’
• Xdebug: Overview, Features, and Benefits
• Xdebug Installation and Setup
• Application Debugging and Profiling
Today’s Topics
Our Goal
Understanding Debugging and Context
Evaluating, understanding, and
validating how your application works.
What is ‘debugging’?
var_dump()
Context Matters
Xdebug Overview
• 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?
• Debugging support
• Stack trace view
• Profiling
• Code coverage analysis
• Function logging
Features
• 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
• Xdebug support exists in over a dozen IDES, including:
• PhpStorm
• Eclipse
• NetBeans
• Plain text editors too (with extensions)!
• VIM
• Sublime Text
• Notepad++
Editor Support
Setup and Configuration
Assumptions
• Pre-installed w/ some environments (MAMP, XAMPP, Vagrant)
• Install from source
• PEAR/PECL
• Detailed instructions at http://xdebug.org/docs/install
Installation
• 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
• 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
Using Xdebug
• 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
• 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
• 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
• Profiling
• KCacheGrind (Linux)
• Webgrind: https://github.com/jokkedk/webgrind
• Debugging
• MacGDBp (OSX)
• Aforementioned browser extensions
Tools
Demo
• 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
Thank You!
Feedback
http://joind.in/15183
Questions?
Email: jeremy@jmichaelward.com
Twitter: @_jmichaelward
IRC: jmichaelward

Weitere ähnliche Inhalte

Was ist angesagt?

Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013
Jan Gehring
 
From Test to Live with Rex
From Test to Live with RexFrom Test to Live with Rex
From Test to Live with Rex
Jan Gehring
 
Seedhack MongoDB 2011
Seedhack MongoDB 2011Seedhack MongoDB 2011
Seedhack MongoDB 2011
Rainforest QA
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshop
seleniumconf
 

Was ist angesagt? (20)

Ansible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL MeetupAnsible 101 - Presentation at Ansible STL Meetup
Ansible 101 - Presentation at Ansible STL Meetup
 
Ansible
AnsibleAnsible
Ansible
 
Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
 
Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013
 
ChinaNetCloud - Zabbix Monitoring System Overview
ChinaNetCloud - Zabbix Monitoring System OverviewChinaNetCloud - Zabbix Monitoring System Overview
ChinaNetCloud - Zabbix Monitoring System Overview
 
Caching basics in PHP
Caching basics in PHPCaching basics in PHP
Caching basics in PHP
 
Server Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.jsServer Check.in case study - Drupal and Node.js
Server Check.in case study - Drupal and Node.js
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Vault
VaultVault
Vault
 
About Caching
About CachingAbout Caching
About Caching
 
NginX - good practices, tips and advanced techniques
NginX - good practices, tips and advanced techniquesNginX - good practices, tips and advanced techniques
NginX - good practices, tips and advanced techniques
 
OSGi Community Event 2010 - Automated Semantic Versioning for OSGi Bundles
OSGi Community Event 2010 - Automated Semantic Versioning for OSGi BundlesOSGi Community Event 2010 - Automated Semantic Versioning for OSGi Bundles
OSGi Community Event 2010 - Automated Semantic Versioning for OSGi Bundles
 
Configuration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needsConfiguration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needs
 
Introducing DeploYii 0.5
Introducing DeploYii 0.5Introducing DeploYii 0.5
Introducing DeploYii 0.5
 
Seguranca em APP Rails
Seguranca em APP RailsSeguranca em APP Rails
Seguranca em APP Rails
 
From Test to Live with Rex
From Test to Live with RexFrom Test to Live with Rex
From Test to Live with Rex
 
Seedhack MongoDB 2011
Seedhack MongoDB 2011Seedhack MongoDB 2011
Seedhack MongoDB 2011
 
Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)
 
Ansible in CI
Ansible in CIAnsible in CI
Ansible in CI
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshop
 

Andere mochten auch

Real Estate Resume
Real Estate ResumeReal Estate Resume
Real Estate Resume
Leigh Disney
 
ahsan habib paper
ahsan habib paperahsan habib paper
ahsan habib paper
ahsan habib
 
Rapport_SISTA_VERSION
Rapport_SISTA_VERSIONRapport_SISTA_VERSION
Rapport_SISTA_VERSION
Kika Diestre
 

Andere mochten auch (14)

NYHTbrochurePRINT
NYHTbrochurePRINTNYHTbrochurePRINT
NYHTbrochurePRINT
 
Ejercicio 17 pag 87
Ejercicio 17 pag 87Ejercicio 17 pag 87
Ejercicio 17 pag 87
 
Real Estate Resume
Real Estate ResumeReal Estate Resume
Real Estate Resume
 
Julkisuus osana asiantuntijatyötä 15.1.2014
Julkisuus osana asiantuntijatyötä 15.1.2014Julkisuus osana asiantuntijatyötä 15.1.2014
Julkisuus osana asiantuntijatyötä 15.1.2014
 
Debugging WooCommerce - WooConf Talk
Debugging WooCommerce - WooConf TalkDebugging WooCommerce - WooConf Talk
Debugging WooCommerce - WooConf Talk
 
ahsan habib paper
ahsan habib paperahsan habib paper
ahsan habib paper
 
Actividad 3
Actividad 3Actividad 3
Actividad 3
 
Rapport_SISTA_VERSION
Rapport_SISTA_VERSIONRapport_SISTA_VERSION
Rapport_SISTA_VERSION
 
La colaboración público-privada en los entes mixtos locales de gestión y pro...
 La colaboración público-privada en los entes mixtos locales de gestión y pro... La colaboración público-privada en los entes mixtos locales de gestión y pro...
La colaboración público-privada en los entes mixtos locales de gestión y pro...
 
UNWTO Global Report on Meetings Industry 2013
UNWTO Global Report on Meetings Industry 2013UNWTO Global Report on Meetings Industry 2013
UNWTO Global Report on Meetings Industry 2013
 
Inversión en Viajes y Turismo en las Américas. Estudio WTTC 2014
Inversión en Viajes y Turismo en las Américas. Estudio WTTC 2014Inversión en Viajes y Turismo en las Américas. Estudio WTTC 2014
Inversión en Viajes y Turismo en las Américas. Estudio WTTC 2014
 
Citizen Evaluation of Property Development
Citizen Evaluation of Property DevelopmentCitizen Evaluation of Property Development
Citizen Evaluation of Property Development
 
A new approach to b2b marketing in professional services
A new approach to b2b marketing in professional servicesA new approach to b2b marketing in professional services
A new approach to b2b marketing in professional services
 
ανακυκλωση
ανακυκλωσηανακυκλωση
ανακυκλωση
 

Ähnlich wie Getting Started With Xdebug

Php code profiling_using_x_debug
Php code profiling_using_x_debugPhp code profiling_using_x_debug
Php code profiling_using_x_debug
Gennady Feldman
 
WordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best PracticesWordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best Practices
ryanduff
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
Bachkoutou Toutou
 
Benefits of an Open environment with Wakanda
Benefits of an Open environment with WakandaBenefits of an Open environment with Wakanda
Benefits of an Open environment with Wakanda
Alexandre Morgaut
 

Ähnlich wie Getting Started With Xdebug (20)

doing_it_right() with WordPress
doing_it_right() with WordPressdoing_it_right() with WordPress
doing_it_right() with WordPress
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPress
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production Parity
 
Xdebug
XdebugXdebug
Xdebug
 
Zend Framwork configurations
Zend Framwork configurationsZend Framwork configurations
Zend Framwork configurations
 
Xdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP codeXdebug - Your first, last, and best option for troubleshooting PHP code
Xdebug - Your first, last, and best option for troubleshooting PHP code
 
Php code profiling_using_x_debug
Php code profiling_using_x_debugPhp code profiling_using_x_debug
Php code profiling_using_x_debug
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
Web Fundamental
Web FundamentalWeb Fundamental
Web Fundamental
 
WordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best PracticesWordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best Practices
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Benefits of an Open environment with Wakanda
Benefits of an Open environment with WakandaBenefits of an Open environment with Wakanda
Benefits of an Open environment with Wakanda
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
Improving qa on php projects
Improving qa on php projectsImproving qa on php projects
Improving qa on php projects
 
PHP Profiling/performance
PHP Profiling/performancePHP Profiling/performance
PHP Profiling/performance
 
Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
 
Php reports sumit
Php reports sumitPhp reports sumit
Php reports sumit
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's Rye
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Getting Started With Xdebug

  • 1. Jeremy Ward Pacific Northwest PHP Conference September 12, 2015 Getting Started With Xdebug
  • 2. • Developer at Westwerk • Drummer for Loud Nerves • Board game geek • Fan of stand-up comedy About Me
  • 3. • About ‘Debugging’ • Xdebug: Overview, Features, and Benefits • Xdebug Installation and Setup • Application Debugging and Profiling Today’s Topics
  • 4.
  • 6.
  • 8. Evaluating, understanding, and validating how your application works. What is ‘debugging’?
  • 10.
  • 13. • 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?
  • 14. • Debugging support • Stack trace view • Profiling • Code coverage analysis • Function logging Features
  • 15. • 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
  • 16. • Xdebug support exists in over a dozen IDES, including: • PhpStorm • Eclipse • NetBeans • Plain text editors too (with extensions)! • VIM • Sublime Text • Notepad++ Editor Support
  • 19. • Pre-installed w/ some environments (MAMP, XAMPP, Vagrant) • Install from source • PEAR/PECL • Detailed instructions at http://xdebug.org/docs/install Installation
  • 20. • 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
  • 21. • 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
  • 23. • 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
  • 24. • 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
  • 25. • 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
  • 26. • Profiling • KCacheGrind (Linux) • Webgrind: https://github.com/jokkedk/webgrind • Debugging • MacGDBp (OSX) • Aforementioned browser extensions Tools
  • 27. Demo
  • 28. • 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