xdebug
Shedding light on your code.
Who Is This Guy?
Bryce Embry
Application Developer at
Vanderbilt University Medical Center
Devoted user of Opera web browser
Ambivalent user of Windows Desktop
Handyman, cook, hobbyist musician, husband, & father
In this session…
▪ What is xdebug?
▪ Getting Started
▪ Tracing
▪ Profiling
▪ Debugging
▪ Debug Demo
What is xdebug
Tracing
List all the
functions being
called, and who is
calling them.
Profiling
See how long
each of those
function calls
takes
Debugging
Pause code execution
See variable values
Walk through code one
step at a time
Code Coverage
Identify which lines of a
script have been
executed during a
request.
This feature is used by
other programs to create
test coverage reports
Enhanced PHP Error Messages
Without
xdebug
With
xdebug
Getting Started
Two Part Install
▪ Server:
– Install xdebug extension to PHP
– Configure php.ini
– Restart web server
▪ Client
– Install browser extension
Server: Install Xdebug
http://xdebug.org/wizard.php
Server: Configure php
php.ini
phpinfo()
Client: URL Triggers
To trigger xdebug, need to use a cookie or add parameters to
the URL.
Doing this by hand violates the programming principle, “Work hard
to be lazy”.
Client: Bookmarklets
PHPStorm has a site to create
“bookmarklets” to add trigger
parameters to your URL.
https://www.jetbrains.com/phpstorm/marklets/
Client: Browser Extension
Firefox has an
extension
available.
Client: Browser Extension
Chrome has a better extension,
especially if you look at the
contributors.
Tracing
Running a trace
1. In
browser,
activate
trace
2. Load
web page
3. On server,
find trace file
4. Review
trace file
Trace Sample
foreach loop vs array_map
Sample Configurations
phpinfo
()
php.i
ni
https://xdebug.org/docs/execution_trace
Configuration Options
trace_enable_trigger Turn “on” to allow traces
trace_enable_trigger_valu
e
Sets a passcode that must be passed by browser to start a trace
trace_format Sets the output format for a trace as human-readable, machine readable, or HTML
trace_options Turn “on” to have trace data appended to a file instead of creating new file.
trace_output_dir Sets directory where trace file will be saved.
Make sure this directory is readable by the PHP process (ie Apache)
If using HTML output, set this as a web-accessible directory
trace_output_name Sets name for trace file. The extension “.xt” will be appended by default.
Can include variables such as:
%t = timestamp %R = $_SERVER[‘REQUEST_URI’]
Nifty Tool: xdebug-trace-tree
https://github.com/splitbrain/xdebug-trace-tree
Profiling
Running a profile
1. In browser,
activate
profile
2. Load web
page
3. Look for new
cachegrind file on
server.
4. Open in IDE
or KcacheGrind
Sample Profiles
kCacheGrin
d
PHPStorm
Sample Configurations
phpinfo
()
php.ini
Configuration Options
profiler_append Turn “on” to have data appended to existing file instead of creating a new file.
profiler_enable Turn “on” if you want constant profiling. (Hint: You don’t.)
profiler_enable_trigger Turn “on” to allow profiling to be activated by a browser trigger
profiler_enable_trigger_valu
e
Sets a passcode that must be passed by browser to start a profile
profiler_output_dir Sets directory where profile file will be saved.
Make sure this directory is readable by the PHP process (ie Apache)
profiler_output_name Sets name for profile file.
Can include variables such as:
%t = timestamp %s = script name
Nifty Tool: kcachegrind
https://kcachegrind.github.io/html/Home.html
Debugging
How debugging works
Web server IDE & Browser
http request / 80
dbgp / 9000
http response / 80
Debugging with xdebug
1. Set pause
point in code
2. Turn
on
listening
in IDE
3. Enable
debug in
browser
5. Walk through
code in the IDE
as it is executed
4. Load page
in browser
Sample Configurations
phpinfo
()
php.ini
Configuration Options
remote_enable Turn “on” to enable debugging
Remote_host Set the host name or IP address of the debugging client computer.
Can only have one value, so good way to lock down xdebug to only one user.
Remote_connect_back Turn “on” to ignore the remote_host setting and connect back to any xdebug
client. Useful if multiple developers are running from same debug server.
Remote_port Set the port xdebug uses for communication. Default is 9000.
Remote_mode Set to “req” to connect to debug client when code begins.
Set to “jit” to connect to debut client only on failure.
Tip: Map your code
If you have two
copies of code (local
and server), make
sure they are mapped
in the IDE and in-
sync. Otherwise,
xdebug will lie to you.
Tip: Debugging is one-way
Once you’ve passed
a point in code,
you can’t go back.
Tip: Navigating Code
Step
over
Step
into
Composer/Autoload/Classloader
Symfony/Component/Routing
Step
Out
Debug Demo
To show in demo
▪ Start / stop debug process
▪ Stepping through code
▪ Conditional break points
▪ Modifying values in running code
Questions?
End Notes
Resources:
xdebug.org
www.thornview.com
Presentation by:
Bryce.Embry@vanderbilt.edu
Fonts:
Sketchy - http://dl.dafont.com/dl/?f=sketchy
DJB Chalk It Up - http://dl.dafont.com/dl/?f=djb_chalk_it_up
Source Sans Pro - http://www.fontsquirrel.com/fonts/source-sans-pro

More Related Content

PPTX
Xdebug - Your first, last, and best option for troubleshooting PHP code
PDF
LCA2014 - Introduction to Go
PDF
Ch ch-changes cake php2
PDF
Profiling PHP with Xdebug / Webgrind
PDF
Evented applications with RabbitMQ and CakePHP
PPTX
20151229 wnmp & phalcon micro app - part I
PDF
Nginx pres
PDF
Xdebug - Your first, last, and best option for troubleshooting PHP code
LCA2014 - Introduction to Go
Ch ch-changes cake php2
Profiling PHP with Xdebug / Webgrind
Evented applications with RabbitMQ and CakePHP
20151229 wnmp & phalcon micro app - part I
Nginx pres

What's hot (19)

PDF
Debugging PHP With Xdebug
PDF
Quick flask an intro to flask
PPTX
Xdebug, KCacheGrind and Webgrind with WampServer
PPTX
Socket programming with php
PDF
PDF
PECL Picks - Extensions to make your life better
PDF
Zero Downtime Deployment with Ansible
ODP
Drizzle plugins
PPT
Write book in markdown
PDF
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
PDF
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
PDF
X-Debug in Php Storm
PDF
DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet
PPTX
PSGI and Plack from first principles
PDF
Apache and PHP: Why httpd.conf is your new BFF!
PDF
Javascript #2.2 : jQuery
PDF
Ops for everyone - John Britton
PDF
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
PPT
Nodejs quick start
Debugging PHP With Xdebug
Quick flask an intro to flask
Xdebug, KCacheGrind and Webgrind with WampServer
Socket programming with php
PECL Picks - Extensions to make your life better
Zero Downtime Deployment with Ansible
Drizzle plugins
Write book in markdown
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
X-Debug in Php Storm
DevOps: Falando um pouco sobre desenvolvimento orientado a testes com Puppet
PSGI and Plack from first principles
Apache and PHP: Why httpd.conf is your new BFF!
Javascript #2.2 : jQuery
Ops for everyone - John Britton
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Nodejs quick start
Ad

Similar to Xdebug (20)

PDF
Debugging PHP with xDebug inside of Eclipse PDT 2.1
PDF
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
PPT
Php Debugger
PDF
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
PDF
Xdebug from a to x
PDF
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
PPT
Download It
PDF
DevOpsDays Singapore - Continuous Auditing with Compliance as Code
PPT
Php Best Practices
PPT
Php Best Practices
PPT
PHP: Debugger, Profiler and more
PDF
WordPress At Scale. WordCamp Dhaka 2019
PDF
Pyramid Deployment and Maintenance
PDF
TDD for joomla extensions
PDF
Comment améliorer le quotidien des Développeurs PHP ?
PDF
Chef - industrialize and automate your infrastructure
PDF
Getting Started With Xdebug
PDF
Behavior & Specification Driven Development in PHP - #OpenWest
PPT
Open Source Web Technologies
PDF
Session10-PHP Misconfiguration
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Php Debugger
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Xdebug from a to x
DevSec Delight with Compliance as Code - Matt Ray - AgileNZ 2017
Download It
DevOpsDays Singapore - Continuous Auditing with Compliance as Code
Php Best Practices
Php Best Practices
PHP: Debugger, Profiler and more
WordPress At Scale. WordCamp Dhaka 2019
Pyramid Deployment and Maintenance
TDD for joomla extensions
Comment améliorer le quotidien des Développeurs PHP ?
Chef - industrialize and automate your infrastructure
Getting Started With Xdebug
Behavior & Specification Driven Development in PHP - #OpenWest
Open Source Web Technologies
Session10-PHP Misconfiguration
Ad

Recently uploaded (20)

PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PDF
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
PPTX
Cybersecurity: Protecting the Digital World
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
PDF
Workplace Software and Skills - OpenStax
PDF
BoxLang Dynamic AWS Lambda - Japan Edition
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PPTX
Computer Software - Technology and Livelihood Education
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
CNN LeNet5 Architecture: Neural Networks
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PDF
E-Commerce Website Development Companyin india
PPTX
Download Adobe Photoshop Crack 2025 Free
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
Cybersecurity: Protecting the Digital World
iTop VPN Crack Latest Version Full Key 2025
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
Workplace Software and Skills - OpenStax
BoxLang Dynamic AWS Lambda - Japan Edition
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
DNT Brochure 2025 – ISV Solutions @ D365
Computer Software - Technology and Livelihood Education
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
CNN LeNet5 Architecture: Neural Networks
CCleaner 6.39.11548 Crack 2025 License Key
E-Commerce Website Development Companyin india
Download Adobe Photoshop Crack 2025 Free
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
WiFi Honeypot Detecscfddssdffsedfseztor.pptx

Xdebug

Editor's Notes

  • #2: Talk spurred by Jim – struggling to use xdebug. Now, hooked on xdebug and wouldn’t want to work without it. Theme: xdebug is like light in code
  • #3: Past lives – teacher, IT support manager, Director of IT Programmer 10 months – long enough for a baby, but not enough to understand parenthood Opera – UI (tabs, speed dial, etc.), Coast for iPad, Bork Bork 2003.
  • #4: Five features, will cover 2.5
  • #5: One concept, five tools. Concept = document running code
  • #6: Trace helps with new code base. How does the first page load (5,000 function calls in framework)
  • #8: In unfamiliar framework, see pre-loaded global values
  • #9: Required tool to generate code coverage reports (that’s how we started) Note: Green and red are just CSS settings
  • #10: Didn’t realize these tracebacks were special at first.
  • #11: Summary: Race, Profile, Debug, Coverage, Traceback Now, how to install
  • #13: Our dev server managed by sys admin behind firewall. Messy setup. Local xampp, not so tough. Cool tool, though not entirely accurate.
  • #14: Note: zend_extension, not just “extension”
  • #15: Need to communicate with xdebug to run scripts. Here’s how.
  • #16: Bookmarklets don’t show “on” vs “off”
  • #18: Chrome works on Opera. Cool. Safari – older extension, but just tacking parameter to URL so should work.
  • #21: Playing with functional PHP wondered if array_map was more efficient than a foreach loop.
  • #22: Trigger value – caused issues when I forgot. Hence mods to extension. Not sure why they are needed. Format: 0 = human, 1 = computer, 2 = html Output_dir - make sure it’s writable by web server.
  • #24: Allows to collapse trace branches Note info – time, memory, etc.
  • #25: The same a traces, with different pictures.
  • #28: Same as traces, but different options for output_name Note cachegrind format requires special reader.
  • #30: It must be better than PHPStorm because it has more colors.
  • #31: All other tools are read / report. Debug requires coordinated communication. More complicated.
  • #32: Request has xdebug parameter Coordinate over dbgp during execution Responses sent as needed.
  • #35: Autostart – always try to run Remote_connect_back vs remote_host – one or the other, not both. Connect_back good for shared dev box. Firewall issue: port 9000 blocked. Remote host = localhost.
  • #37: Debug shows executing a blank line
  • #38: Too many clicks = start over
  • #39: “step over” != “skip”
  • #40: Describe setup: xampp local server with xdebug