SlideShare a Scribd company logo
1 of 50
Download to read offline
PHP Québec
Novembre 2019 Eric Hogue
Au secours, mon
application est
brisée - Ou comment
déboguer
1
If you're good at the
debugger it means you
spent a lot of time
debugging. I don't want you
to be good at the debugger.
- Uncle Bob 2
Idées préconçues
● Si tu n’utilise pas un débogueurs, tu es un amateur
● Les débogueurs sont pour les paresseux
● Il ne faut jamais déboguer en prod
● ...
3
Les bugs sont innévitables
4
Pourquoi il y a autant de bug?
5
Apprendre à déboguer
6
Bogue
7
Avant de sauter
dans le code
8
Travail d’investigation
9
Hypothèse
10
Communication
11
Argent
12
Communication constante
13
Temps
14
Déboguer
15
Reproduire le bug
16
Répliquer la production
17
Changements
18
Logs
19
Les outils
20
PHP
● echo
● die
● var_dump
● print_r
● error_log(print_r($something, true))
● error_log(__FILE__ . ‘ - ‘ . __LINE__)
21
Charles
22
patreon.com/derickr
23
24
● Installer Xdebug
● Configurer Xdebug
Installation / Configuration
25
Configurations Xdebug
● xdebug.default_enable
● xdebug.halt_level
● xdebug.remote_enable
● xdebug.remote_autostart
● xdebug.remote_host
● xdebug.remote_connect_back
● xdebug.scream
● Et beaucoup d’autres
○ https://xdebug.org/docs/all_settings
26
Installation / Configuration
● Installer Xdebug
● Configurer Xdebug
27
● Installer PhpStorm
○ https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html
● Installer une extension dans votre navigateur
Points d’arrêts
CTRL-F8
28
Points d’arrêts
29
Écouter les connections
30
Rafraîchir la page
31
Exécution du code
● Exécuter une ligne - F8
● Entrer dans une méthode - F7
● Sortir d’une méthode - Shift-F8
● Relancer l’exécution - F9
32
Inspecter les variables
33
Inspecter les variables
34
Inspecter les variables
35
Diviser et conquérir
36
Pièges
● Oublier le débogueur - Bloquer d’autres scripts / pages
○ composer
○ Même problème avec Charles
● Installer Xdebug en prod
○ xdebug.remote_autostart
37
Pièges
● Oublier le débogueur - Bloquer d’autres scripts / pages
○ composer
○ Même problème avec Charles
● Installer Xdebug en prod
○ xdebug.remote_autostart
● Outils qui ne sont pas à jour
○ JetBrains Toolbox
38
Régler le bug
39
Tests
40
Pas de bébé
41
Trouver la cause première
42
Comment s’améliorer
43
Laissez des traces
44
try {...} catch (Throwable $e) {//vide}
45
Code
● Simple
● Revues de code
● Tests
○ TDD
46
Pratique
47
Regarder quelqu’un de plus expérimenté
48
Eric Hogue
http://twitter.com/ehogue
https://joind.in/talk/7eb91
Questions?
49
● Library - a.canvas.of.light - https://www.flickr.com/photos/jhlau/
● Sherlock Holmes the invisible detective - Matt Brown -
https://www.flickr.com/photos/londonmatt/14964181994/
● Money - Pictures of Money - https://www.flickr.com/photos/pictures-of-money/17123251389/
● Communications - Maurits Verbiest -
https://www.flickr.com/photos/mauritsverbiest/16530871592/
● Marine Chronometer- Arnold & Dent, No. 1131 - Will Fisher -
https://www.flickr.com/photos/fireatwillrva/31370473292/
● Wiki servers - Domas Mituzas - https://www.flickr.com/photos/midom/423471686
● Journals - Meagan - https://www.flickr.com/photos/peroshenka/7064964081/
● cracks in the ice - Zervas - https://flickr.com/photos/zervas/16322567572/
● Baby Feet - Brian DePalo - https://flickr.com/photos/depalo/15237576137/
● Roots - eltpics - https://flickr.com/photos/eltpics/14917034121/
● Traces - Adrien Sifre - https://flickr.com/photos/adriensifre/8403355648/
● Trading Cards - Minh Hoang - https://flickr.com/photos/minhimalism/5516898844/
● paired programming east agile - abstract - Lawrence Sinclair -
https://www.flickr.com/photos/lws/8319713379/
50

More Related Content

Similar to Au secours, mon application est brisée - Ou comment déboguer

Tdd en action - découverte
Tdd en action - découverteTdd en action - découverte
Tdd en action - découverteEric Mignot
 
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidementENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidementHoracio Gonzalez
 
XebiCon'16 : La programmation concurrente en Go. Par Jérome Doucet et Diana O...
XebiCon'16 : La programmation concurrente en Go. Par Jérome Doucet et Diana O...XebiCon'16 : La programmation concurrente en Go. Par Jérome Doucet et Diana O...
XebiCon'16 : La programmation concurrente en Go. Par Jérome Doucet et Diana O...Publicis Sapient Engineering
 
Enib cours c.a.i. web - séance #5 - j’ai besoin d’une appli web rapidement !
Enib   cours c.a.i. web - séance #5 - j’ai besoin d’une appli web rapidement !Enib   cours c.a.i. web - séance #5 - j’ai besoin d’une appli web rapidement !
Enib cours c.a.i. web - séance #5 - j’ai besoin d’une appli web rapidement !Horacio Gonzalez
 
FinistJUG - J’ai besoin d’une appli web rapidement
FinistJUG -   J’ai besoin d’une appli web rapidementFinistJUG -   J’ai besoin d’une appli web rapidement
FinistJUG - J’ai besoin d’une appli web rapidementHoracio Gonzalez
 
20131024 qualité de code et sonar - mug lyon
20131024   qualité de code et sonar - mug lyon20131024   qualité de code et sonar - mug lyon
20131024 qualité de code et sonar - mug lyonClement Bouillier
 
Commencer avec le tdd
Commencer avec le tddCommencer avec le tdd
Commencer avec le tddEric Hogue
 
2010 agile conférence - Comment vendre les tests automatisés
2010 agile conférence - Comment vendre les tests automatisés2010 agile conférence - Comment vendre les tests automatisés
2010 agile conférence - Comment vendre les tests automatisésNathaniel Richand
 
Présentation TDD UQAM
Présentation TDD UQAMPrésentation TDD UQAM
Présentation TDD UQAMNicholas Lemay
 
10 ans de Code (Agile Bordeaux 2019).pptx
10 ans de Code (Agile Bordeaux 2019).pptx10 ans de Code (Agile Bordeaux 2019).pptx
10 ans de Code (Agile Bordeaux 2019).pptxGuillaume Saint Etienne
 
The worst practices for Magento
The worst practices for MagentoThe worst practices for Magento
The worst practices for MagentoLe Bot Christophe
 
Tbonset agile france2015
Tbonset agile france2015Tbonset agile france2015
Tbonset agile france2015Thomas Bonset
 
Agile Tour 2010 - Mise en place d'un projet agile
Agile Tour 2010 - Mise en place d'un projet agileAgile Tour 2010 - Mise en place d'un projet agile
Agile Tour 2010 - Mise en place d'un projet agileLaurent Deséchalliers
 
AT2010 Mise place d'un projet Agile
AT2010 Mise place d'un projet AgileAT2010 Mise place d'un projet Agile
AT2010 Mise place d'un projet AgileNormandy JUG
 
Spring Batch - Julien Jakubowski - November 2010
Spring Batch - Julien Jakubowski - November 2010Spring Batch - Julien Jakubowski - November 2010
Spring Batch - Julien Jakubowski - November 2010JUG Lausanne
 
Trucs et astuces pour débuter sereinement
Trucs et astuces pour débuter sereinementTrucs et astuces pour débuter sereinement
Trucs et astuces pour débuter sereinementLaurence Vagner
 
Coding Dojo - Kata sur le pilotage par les tests d'acceptances (ATDD)
Coding Dojo - Kata sur le pilotage par les tests d'acceptances (ATDD)Coding Dojo - Kata sur le pilotage par les tests d'acceptances (ATDD)
Coding Dojo - Kata sur le pilotage par les tests d'acceptances (ATDD)Agile Tour Genève
 

Similar to Au secours, mon application est brisée - Ou comment déboguer (20)

Doc app cracker
Doc app crackerDoc app cracker
Doc app cracker
 
Tdd en action - découverte
Tdd en action - découverteTdd en action - découverte
Tdd en action - découverte
 
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidementENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
ENIB 2013-2014 - CAI Web #3: J’ai besoin d’une appli web rapidement
 
XebiCon'16 : La programmation concurrente en Go. Par Jérome Doucet et Diana O...
XebiCon'16 : La programmation concurrente en Go. Par Jérome Doucet et Diana O...XebiCon'16 : La programmation concurrente en Go. Par Jérome Doucet et Diana O...
XebiCon'16 : La programmation concurrente en Go. Par Jérome Doucet et Diana O...
 
Enib cours c.a.i. web - séance #5 - j’ai besoin d’une appli web rapidement !
Enib   cours c.a.i. web - séance #5 - j’ai besoin d’une appli web rapidement !Enib   cours c.a.i. web - séance #5 - j’ai besoin d’une appli web rapidement !
Enib cours c.a.i. web - séance #5 - j’ai besoin d’une appli web rapidement !
 
FinistJUG - J’ai besoin d’une appli web rapidement
FinistJUG -   J’ai besoin d’une appli web rapidementFinistJUG -   J’ai besoin d’une appli web rapidement
FinistJUG - J’ai besoin d’une appli web rapidement
 
20131024 qualité de code et sonar - mug lyon
20131024   qualité de code et sonar - mug lyon20131024   qualité de code et sonar - mug lyon
20131024 qualité de code et sonar - mug lyon
 
Commencer avec le tdd
Commencer avec le tddCommencer avec le tdd
Commencer avec le tdd
 
2010 agile conférence - Comment vendre les tests automatisés
2010 agile conférence - Comment vendre les tests automatisés2010 agile conférence - Comment vendre les tests automatisés
2010 agile conférence - Comment vendre les tests automatisés
 
Présentation TDD UQAM
Présentation TDD UQAMPrésentation TDD UQAM
Présentation TDD UQAM
 
10 ans de Code (Agile Bordeaux 2019).pptx
10 ans de Code (Agile Bordeaux 2019).pptx10 ans de Code (Agile Bordeaux 2019).pptx
10 ans de Code (Agile Bordeaux 2019).pptx
 
The worst practices for Magento
The worst practices for MagentoThe worst practices for Magento
The worst practices for Magento
 
Tbonset agile france2015
Tbonset agile france2015Tbonset agile france2015
Tbonset agile france2015
 
Agile Tour 2010 - Mise en place d'un projet agile
Agile Tour 2010 - Mise en place d'un projet agileAgile Tour 2010 - Mise en place d'un projet agile
Agile Tour 2010 - Mise en place d'un projet agile
 
AT2010 Mise place d'un projet Agile
AT2010 Mise place d'un projet AgileAT2010 Mise place d'un projet Agile
AT2010 Mise place d'un projet Agile
 
Logiciels 3d-112-ktcufc
Logiciels 3d-112-ktcufcLogiciels 3d-112-ktcufc
Logiciels 3d-112-ktcufc
 
Spring Batch - Julien Jakubowski - November 2010
Spring Batch - Julien Jakubowski - November 2010Spring Batch - Julien Jakubowski - November 2010
Spring Batch - Julien Jakubowski - November 2010
 
Trucs et astuces pour débuter sereinement
Trucs et astuces pour débuter sereinementTrucs et astuces pour débuter sereinement
Trucs et astuces pour débuter sereinement
 
Hackerspace jan-2013
Hackerspace jan-2013Hackerspace jan-2013
Hackerspace jan-2013
 
Coding Dojo - Kata sur le pilotage par les tests d'acceptances (ATDD)
Coding Dojo - Kata sur le pilotage par les tests d'acceptances (ATDD)Coding Dojo - Kata sur le pilotage par les tests d'acceptances (ATDD)
Coding Dojo - Kata sur le pilotage par les tests d'acceptances (ATDD)
 

More from Eric Hogue

Introduction à l'intégration continue en PHP
Introduction à l'intégration continue en PHPIntroduction à l'intégration continue en PHP
Introduction à l'intégration continue en PHPEric Hogue
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDDEric Hogue
 
Introduction à l’intégration continue avec Jenkins
Introduction à l’intégration continue avec JenkinsIntroduction à l’intégration continue avec Jenkins
Introduction à l’intégration continue avec JenkinsEric Hogue
 
Introduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with JenkinsIntroduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with JenkinsEric Hogue
 
Guarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingGuarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingEric Hogue
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHPEric Hogue
 
La sécurité des communications avec GPG
La sécurité des communications avec GPGLa sécurité des communications avec GPG
La sécurité des communications avec GPGEric Hogue
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Eric Hogue
 
Continuous Testing
Continuous TestingContinuous Testing
Continuous TestingEric Hogue
 
Introduction to ci with jenkins
Introduction to ci with jenkinsIntroduction to ci with jenkins
Introduction to ci with jenkinsEric Hogue
 
Integration continue
Integration continueIntegration continue
Integration continueEric Hogue
 

More from Eric Hogue (11)

Introduction à l'intégration continue en PHP
Introduction à l'intégration continue en PHPIntroduction à l'intégration continue en PHP
Introduction à l'intégration continue en PHP
 
Commencer avec le TDD
Commencer avec le TDDCommencer avec le TDD
Commencer avec le TDD
 
Introduction à l’intégration continue avec Jenkins
Introduction à l’intégration continue avec JenkinsIntroduction à l’intégration continue avec Jenkins
Introduction à l’intégration continue avec Jenkins
 
Introduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with JenkinsIntroduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with Jenkins
 
Guarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous TestingGuarding Your Code Against Bugs with Continuous Testing
Guarding Your Code Against Bugs with Continuous Testing
 
Continuous testing In PHP
Continuous testing In PHPContinuous testing In PHP
Continuous testing In PHP
 
La sécurité des communications avec GPG
La sécurité des communications avec GPGLa sécurité des communications avec GPG
La sécurité des communications avec GPG
 
Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014Getting started with TDD - Confoo 2014
Getting started with TDD - Confoo 2014
 
Continuous Testing
Continuous TestingContinuous Testing
Continuous Testing
 
Introduction to ci with jenkins
Introduction to ci with jenkinsIntroduction to ci with jenkins
Introduction to ci with jenkins
 
Integration continue
Integration continueIntegration continue
Integration continue
 

Au secours, mon application est brisée - Ou comment déboguer