SlideShare a Scribd company logo
1 of 28
<2/>
DDD
Debugger Driven Development
<2/>
<3/>
Hello world!
Carlos Granados
I have been a software developer for more than 30 years. In the development space I have
done everything: I have done games, e-commerce, APIs, backend, frontend, Android, SRE,
DevOps... And I have worked with multiple languages and technologies: C++, PHP
, Java,
JavaScript, SQL, MongoDB, Docker…
PHP 100%
Symfony 100%
Debugging 100%
https://fastdebug.io
Looking for beta users!
<5/>
DDD
Debugger Driven Development
<5/>
- What is Xdebug and some reasons why people don’t use it
- How to enable and configure it in a Symfony project
- Use cases, going beyond just debugging
- Other alternatives
<6/>
What is Xdebug ?
The most widely used step-by-
step debugger for the PHP
language.
An open source PHP
extension created by
Derick Rethans and
launched in 2002
Provides all the expected
tools: breakpoints, step-by-
step, stack traces, variables,
expression evaluation…
It is more than a debugger:
profiling, code coverage,
tracing, improved error
handling…
https://xdebug.org/
2 0 1 9 . A l l R i g h t s R e s e r v e d
<7/>
2 0 1 9 . A l l R i g h t s R e s e r v e d
<8/>
<9/>
Xdebug is slow
<9/>
- It can make your code between 60% and 300% slower
- It has improved a lot in version 3
- Make sure you use the right configuration
- You can always give FastDebug a go!
<10/>
Xdebug is hard to set up
<10/>
- It can really be difficult to configure and get it running
- You only need to do it once
- Derick has produced some really good helper videos
- I am working on a wizard that will greatly simplify the process
<11/>
I don’t need a debugger
<11/>
- My code is fully tested so I don’t have any bugs
- Don’t believe this can be the case in a real world scenario
- The system is not complex enough
- Symfony has 279 open bugs at the time of writing
<12/>
What do people use
instead of a Xdebug?
D & D
Dump & Die
<13/>
What’s wrong with dump & die?
It only provides a very narrow
and limited view into your code.
It usually requires
several iterations to get
to the heart of the
problem
Many times it can be difficult to
record the output.
Requires modification of your
code, with the possibility of
leaving debugging code behind.
It’s like using alert()!
<14/>
Debugging is like using a
security camera
Using Dump & die is like using a
camera that only takes photos of a
limited part of the scene.
Using a Debugger is like using a
camera that records video and which
you can pan around.
<15/>
1. # Dockerfile
2. ...
3. FROM app_php AS app_php_dev
4.
5. ENV APP_ENV=dev XDEBUG_MODE=off
6. ...
7. RUN set -eux; 
8. install-php-extensions xdebug
Using Xdebug with Symfony
It’s loaded by default if using symfony-docker
<16/>
1. > docker-compose exec php php -v
2.
3. PHP 8.1.19 (cli) (built: May 13 2023 01:08:01) (NTS)
4. Copyright (c) The PHP Group
5. Zend Engine v4.1.19, Copyright (c) Zend Technologies
6. with Zend OPcache v8.1.19, Copyright (c), by Zend Technologies
7. with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans
Using Xdebug with Symfony
Check that it is correctly loaded
<17/>
Using Xdebug with Symfony
Check it using the profiler
<18/>
1. ;docker/php/conf.d/app.dev.ini
2. ...
3. xdebug.client_host = 'host.docker.internal’
4. xdebug.start_with_request = yes
Using Xdebug with Symfony
Enabling the debugger
1. > docker-compose build
<19/>
1. # Dockerfile
2. ...
3. ENV APP_ENV=dev XDEBUG_MODE=debug
Using Xdebug with Symfony
Enabling the debugger
1. > XDEBUG_MODE=debug docker-compose up -d
<20/>
Use the debugger to explore code
Learn about the internals of the
framework (recommended in the
Symfony docs).
Learn about the inner
working of your
dependencies.
Learn about the interface to
APIs, investigate requests and
responses.
Understand legacy code or
functionality which is not well
documented.
<21/>
Use the debugger to test code
Step through code to understand
how it works and what needs to
be tested.
Experiment with your
code to understand how
it behaves under different
inputs.
Look under the hod when
doing black box testing.
Remember that Xdebug can
also provide code coverage,
which is really important for
testing.
<22/>
Use the debugger to review code
Specially useful if you are
reviewing code that you are not
very familiar with.
Check out the previous
version of the code and
check how it works.
Check out the new version of
the code and check out how
the functionality has changed.
Experiment with new inputs to
confirm that the new code is
behaving as expected.
<23/>
Use the debugger for concurrency
Concurrency issues can be
specially difficult to debug or test.
Setup a breakpoint in
one of the processes and
let it run until it is hit.
Set another breakpoint in
another process and again let
it run until it is hit.
Now use step debugging
alternating in both processes to
test what happens when they
run concurrently.
<24/>
Alternatives:
SnapshotDebugger
<24/>
- Based on the Stackdriver Debugger by Google (deprecated)
- Open source tool developed by Google
- Allows you to debug code running in production
- Works using a daemon that communicates with a Firebase RTDB
<25/>
Alternatives:
SnapshotDebugger
<25/>
- Requires adding a PHP extension to enable the breakpoints
- When a breakpoint is hit it just records info without stopping
- When the request finishes this info is sent to Firebase or logged
- It is throttled so that it does not use too much CPU or memory
<26/>
Alternatives:
SnapshotDebugger
<26/>
https://github.com/i6systems/stackdriver-debugger-php-extension
https://github.com/googleapis/google-cloud-php-debugger
https://github.com/GoogleCloudPlatform/snapshot-debugger
<27/>
Alternatives:
Ray
<27/>
- It is like Dump & Die on steroids
- Adds a new “Ray()” function that allows you to record any data
- This information is collected by a desktop application
- It is a paid tool and it requires modifications to your code
https://myray.app/
<28/>
Thank you!
carlos@fastdebug.io
carlos-granados
@carlos_granados

More Related Content

Similar to DDD (Debugger Driven Development)

C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made EasyAlon Fliess
 
How to start your open source project
How to start your open source projectHow to start your open source project
How to start your open source projectEslam Diaa
 
Continuous Integration Step-by-step
Continuous Integration Step-by-stepContinuous Integration Step-by-step
Continuous Integration Step-by-stepMichelangelo van Dam
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Bastian Feder
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Fabrice Bernhard
 
Modernize Your Drupal Development
Modernize Your Drupal DevelopmentModernize Your Drupal Development
Modernize Your Drupal DevelopmentChris Tankersley
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?AFUP_Limoges
 
C/C++ Remote Development Overview
C/C++ Remote Development OverviewC/C++ Remote Development Overview
C/C++ Remote Development OverviewThitipong Jampajeen
 
High Productivity Web Development Workflow
High Productivity Web Development WorkflowHigh Productivity Web Development Workflow
High Productivity Web Development WorkflowVũ Nguyễn
 
High productivity web development workflow - JavaScript Meetup Saigon 2014
High productivity web development workflow - JavaScript Meetup Saigon 2014High productivity web development workflow - JavaScript Meetup Saigon 2014
High productivity web development workflow - JavaScript Meetup Saigon 2014Oliver N
 
Phonegap Development & Debugging
Phonegap Development & DebuggingPhonegap Development & Debugging
Phonegap Development & DebuggingIvano Malavolta
 
No drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwrightNo drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwrightMastacheata1
 
Improve your Java Environment with Docker
Improve your Java Environment with DockerImprove your Java Environment with Docker
Improve your Java Environment with DockerHanoiJUG
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Toolsrjsmelo
 
Debugging Drupal with Xdebug
Debugging Drupal with XdebugDebugging Drupal with Xdebug
Debugging Drupal with XdebugFrank Carey
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안양재동 코드랩
 
Mpeg guide
Mpeg  guideMpeg  guide
Mpeg guidekimsach
 
Android application penetration testing
Android application penetration testingAndroid application penetration testing
Android application penetration testingRoshan Kumar Gami
 

Similar to DDD (Debugger Driven Development) (20)

C# Production Debugging Made Easy
 C# Production Debugging Made Easy C# Production Debugging Made Easy
C# Production Debugging Made Easy
 
How to start your open source project
How to start your open source projectHow to start your open source project
How to start your open source project
 
Continuous Integration Step-by-step
Continuous Integration Step-by-stepContinuous Integration Step-by-step
Continuous Integration Step-by-step
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Modernize Your Drupal Development
Modernize Your Drupal DevelopmentModernize Your Drupal Development
Modernize Your Drupal Development
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?
 
C/C++ Remote Development Overview
C/C++ Remote Development OverviewC/C++ Remote Development Overview
C/C++ Remote Development Overview
 
Android Platform Debugging & Development
Android Platform Debugging & Development Android Platform Debugging & Development
Android Platform Debugging & Development
 
High Productivity Web Development Workflow
High Productivity Web Development WorkflowHigh Productivity Web Development Workflow
High Productivity Web Development Workflow
 
High productivity web development workflow - JavaScript Meetup Saigon 2014
High productivity web development workflow - JavaScript Meetup Saigon 2014High productivity web development workflow - JavaScript Meetup Saigon 2014
High productivity web development workflow - JavaScript Meetup Saigon 2014
 
Phonegap Development & Debugging
Phonegap Development & DebuggingPhonegap Development & Debugging
Phonegap Development & Debugging
 
No drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwrightNo drama here - E2E-testing django with playwright
No drama here - E2E-testing django with playwright
 
Improve your Java Environment with Docker
Improve your Java Environment with DockerImprove your Java Environment with Docker
Improve your Java Environment with Docker
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Tools
 
Xdebug
XdebugXdebug
Xdebug
 
Debugging Drupal with Xdebug
Debugging Drupal with XdebugDebugging Drupal with Xdebug
Debugging Drupal with Xdebug
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Mpeg guide
Mpeg  guideMpeg  guide
Mpeg guide
 
Android application penetration testing
Android application penetration testingAndroid application penetration testing
Android application penetration testing
 

Recently uploaded

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 

Recently uploaded (20)

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 

DDD (Debugger Driven Development)

  • 1.
  • 3. <3/> Hello world! Carlos Granados I have been a software developer for more than 30 years. In the development space I have done everything: I have done games, e-commerce, APIs, backend, frontend, Android, SRE, DevOps... And I have worked with multiple languages and technologies: C++, PHP , Java, JavaScript, SQL, MongoDB, Docker… PHP 100% Symfony 100% Debugging 100%
  • 5. <5/> DDD Debugger Driven Development <5/> - What is Xdebug and some reasons why people don’t use it - How to enable and configure it in a Symfony project - Use cases, going beyond just debugging - Other alternatives
  • 6. <6/> What is Xdebug ? The most widely used step-by- step debugger for the PHP language. An open source PHP extension created by Derick Rethans and launched in 2002 Provides all the expected tools: breakpoints, step-by- step, stack traces, variables, expression evaluation… It is more than a debugger: profiling, code coverage, tracing, improved error handling… https://xdebug.org/
  • 7. 2 0 1 9 . A l l R i g h t s R e s e r v e d <7/>
  • 8. 2 0 1 9 . A l l R i g h t s R e s e r v e d <8/>
  • 9. <9/> Xdebug is slow <9/> - It can make your code between 60% and 300% slower - It has improved a lot in version 3 - Make sure you use the right configuration - You can always give FastDebug a go!
  • 10. <10/> Xdebug is hard to set up <10/> - It can really be difficult to configure and get it running - You only need to do it once - Derick has produced some really good helper videos - I am working on a wizard that will greatly simplify the process
  • 11. <11/> I don’t need a debugger <11/> - My code is fully tested so I don’t have any bugs - Don’t believe this can be the case in a real world scenario - The system is not complex enough - Symfony has 279 open bugs at the time of writing
  • 12. <12/> What do people use instead of a Xdebug? D & D Dump & Die
  • 13. <13/> What’s wrong with dump & die? It only provides a very narrow and limited view into your code. It usually requires several iterations to get to the heart of the problem Many times it can be difficult to record the output. Requires modification of your code, with the possibility of leaving debugging code behind. It’s like using alert()!
  • 14. <14/> Debugging is like using a security camera Using Dump & die is like using a camera that only takes photos of a limited part of the scene. Using a Debugger is like using a camera that records video and which you can pan around.
  • 15. <15/> 1. # Dockerfile 2. ... 3. FROM app_php AS app_php_dev 4. 5. ENV APP_ENV=dev XDEBUG_MODE=off 6. ... 7. RUN set -eux; 8. install-php-extensions xdebug Using Xdebug with Symfony It’s loaded by default if using symfony-docker
  • 16. <16/> 1. > docker-compose exec php php -v 2. 3. PHP 8.1.19 (cli) (built: May 13 2023 01:08:01) (NTS) 4. Copyright (c) The PHP Group 5. Zend Engine v4.1.19, Copyright (c) Zend Technologies 6. with Zend OPcache v8.1.19, Copyright (c), by Zend Technologies 7. with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans Using Xdebug with Symfony Check that it is correctly loaded
  • 17. <17/> Using Xdebug with Symfony Check it using the profiler
  • 18. <18/> 1. ;docker/php/conf.d/app.dev.ini 2. ... 3. xdebug.client_host = 'host.docker.internal’ 4. xdebug.start_with_request = yes Using Xdebug with Symfony Enabling the debugger 1. > docker-compose build
  • 19. <19/> 1. # Dockerfile 2. ... 3. ENV APP_ENV=dev XDEBUG_MODE=debug Using Xdebug with Symfony Enabling the debugger 1. > XDEBUG_MODE=debug docker-compose up -d
  • 20. <20/> Use the debugger to explore code Learn about the internals of the framework (recommended in the Symfony docs). Learn about the inner working of your dependencies. Learn about the interface to APIs, investigate requests and responses. Understand legacy code or functionality which is not well documented.
  • 21. <21/> Use the debugger to test code Step through code to understand how it works and what needs to be tested. Experiment with your code to understand how it behaves under different inputs. Look under the hod when doing black box testing. Remember that Xdebug can also provide code coverage, which is really important for testing.
  • 22. <22/> Use the debugger to review code Specially useful if you are reviewing code that you are not very familiar with. Check out the previous version of the code and check how it works. Check out the new version of the code and check out how the functionality has changed. Experiment with new inputs to confirm that the new code is behaving as expected.
  • 23. <23/> Use the debugger for concurrency Concurrency issues can be specially difficult to debug or test. Setup a breakpoint in one of the processes and let it run until it is hit. Set another breakpoint in another process and again let it run until it is hit. Now use step debugging alternating in both processes to test what happens when they run concurrently.
  • 24. <24/> Alternatives: SnapshotDebugger <24/> - Based on the Stackdriver Debugger by Google (deprecated) - Open source tool developed by Google - Allows you to debug code running in production - Works using a daemon that communicates with a Firebase RTDB
  • 25. <25/> Alternatives: SnapshotDebugger <25/> - Requires adding a PHP extension to enable the breakpoints - When a breakpoint is hit it just records info without stopping - When the request finishes this info is sent to Firebase or logged - It is throttled so that it does not use too much CPU or memory
  • 27. <27/> Alternatives: Ray <27/> - It is like Dump & Die on steroids - Adds a new “Ray()” function that allows you to record any data - This information is collected by a desktop application - It is a paid tool and it requires modifications to your code https://myray.app/