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)

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
 
Dockerize Laravel Application
Dockerize Laravel ApplicationDockerize Laravel Application
Dockerize Laravel ApplicationAfrimadoni Dinata
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushPantheon
 
Adventures in docker compose
Adventures in docker composeAdventures in docker compose
Adventures in docker composeLinkMe Srl
 
PHPUnit with Magento
PHPUnit with MagentoPHPUnit with Magento
PHPUnit with MagentoTu Hoang
 
Android tools for testers
Android tools for testersAndroid tools for testers
Android tools for testersMaksim Kovalev
 
Better Code: Concurrency
Better Code: ConcurrencyBetter Code: Concurrency
Better Code: ConcurrencyPlatonov Sergey
 

Similar to DDD (Debugger Driven Development) (20)

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
 
Dockerize Laravel Application
Dockerize Laravel ApplicationDockerize Laravel Application
Dockerize Laravel Application
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
 
Adventures in docker compose
Adventures in docker composeAdventures in docker compose
Adventures in docker compose
 
PHPUnit with Magento
PHPUnit with MagentoPHPUnit with Magento
PHPUnit with Magento
 
Android tools for testers
Android tools for testersAndroid tools for testers
Android tools for testers
 
Better Code: Concurrency
Better Code: ConcurrencyBetter Code: Concurrency
Better Code: Concurrency
 

Recently uploaded

What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
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
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 

Recently uploaded (20)

What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
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
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 

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/