SlideShare uma empresa Scribd logo
<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

Mais conteúdo relacionado

Mais procurados

Mais procurados (8)

Kinds of adverb
Kinds of adverbKinds of adverb
Kinds of adverb
 
Etre et Avoir ( EX 1 ).pdf
Etre et Avoir ( EX 1 ).pdfEtre et Avoir ( EX 1 ).pdf
Etre et Avoir ( EX 1 ).pdf
 
2000 recent editorial word &amp; phrase for bcs and bank written exam
2000 recent editorial word &amp; phrase for bcs and bank written exam2000 recent editorial word &amp; phrase for bcs and bank written exam
2000 recent editorial word &amp; phrase for bcs and bank written exam
 
No- scalpel vasectomy
No- scalpel vasectomyNo- scalpel vasectomy
No- scalpel vasectomy
 
Grammaire anglaise : comparer
Grammaire anglaise : comparerGrammaire anglaise : comparer
Grammaire anglaise : comparer
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
 
Mazumoon (ssc)
Mazumoon (ssc)Mazumoon (ssc)
Mazumoon (ssc)
 
INFO-SHEET#8 KINDS OF VERB 동사의 종류(Conjugates Rules)
INFO-SHEET#8 KINDS OF VERB 동사의 종류(Conjugates Rules)INFO-SHEET#8 KINDS OF VERB 동사의 종류(Conjugates Rules)
INFO-SHEET#8 KINDS OF VERB 동사의 종류(Conjugates Rules)
 

Semelhante a 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 - 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
 
High Productivity Web Development Workflow
High Productivity Web Development WorkflowHigh Productivity Web Development Workflow
High Productivity Web Development WorkflowVũ Nguyễ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
 

Semelhante a 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 - 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
 
High Productivity Web Development Workflow
High Productivity Web Development WorkflowHigh Productivity Web Development Workflow
High Productivity Web Development Workflow
 
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
 

Último

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024vaibhav130304
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems ApproachNeo4j
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfDeskTrack
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAlluxio, Inc.
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabbereGrabber
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfQ-Advise
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Soroosh Khodami
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesNeo4j
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024Shane Coughlan
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationHelp Desk Migration
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityAPVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityamy56318795
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionWave PLM
 

Último (20)

TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdf
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purityAPVP,apvp apvp High quality supplier safe spot transport, 98% purity
APVP,apvp apvp High quality supplier safe spot transport, 98% purity
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 

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/