Slide 1

Slide 1 text

legacy.joind.in/24817 @SammyK #phpworld Sammy Kaye Powers Dance The Washington, D.C. - 2018 An Intro To Step Debugging in

Slide 2

Slide 2 text

legacy.joind.in/24817 @SammyK #phpworld CLOSER :) Get

Slide 3

Slide 3 text

Thanks to Our Sponsors 2018

Slide 4

Slide 4 text

legacy.joind.in/24817 @SammyK #phpworld Download the slides legacy.joind.in/24817

Slide 5

Slide 5 text

legacy.joind.in/24817 @SammyK #phpworld Does not work for

Slide 6

Slide 6 text

legacy.joind.in/24817 @SammyK #phpworld What is Debugging? Finding and fixing unexpected behavior in code

Slide 7

Slide 7 text

So you write Some Code

Slide 8

Slide 8 text

Does not work

Slide 9

Slide 9 text

legacy.joind.in/24817 @SammyK #phpworld You could check the Error logs

Slide 10

Slide 10 text

legacy.joind.in/24817 @SammyK #phpworld All the things var_dump()

Slide 11

Slide 11 text

legacy.joind.in/24817 @SammyK #phpworld

Slide 12

Slide 12 text

legacy.joind.in/24817 @SammyK #phpworld OR

Slide 13

Slide 13 text

legacy.joind.in/24817 @SammyK #phpworld Use a ‘er

Slide 14

Slide 14 text

legacy.joind.in/24817 @SammyK #phpworld Kate Gregory “ I'm not saying, ‘don't use printf()’, [...] but I think it's insane to use printf() on day one of learning C++. [...] I would first say use the debugger. Episode 30: Stop Teaching C (When Teaching C++)

Slide 15

Slide 15 text

legacy.joind.in/24817 @SammyK #phpworld …now is the perfect time to learn Step Debugging BNEW! Professional

Slide 16

Slide 16 text

legacy.joind.in/24817 @SammyK #phpworld Some step-debugging Jargon

Slide 17

Slide 17 text

legacy.joind.in/24817 @SammyK #phpworld a signal that tells the debugger to pause the execution of your code Breakpoint

Slide 18

Slide 18 text

legacy.joind.in/24817 @SammyK #phpworld run to the next breakpoint Resume Program

Slide 19

Slide 19 text

legacy.joind.in/24817 @SammyK #phpworld advance to the next line in the same scope Step Over

Slide 20

Slide 20 text

legacy.joind.in/24817 @SammyK #phpworld if the next line is a function call, enter the function Step Into

Slide 21

Slide 21 text

legacy.joind.in/24817 @SammyK #phpworld run to the end of the current function Step Out

Slide 22

Slide 22 text

legacy.joind.in/24817 @SammyK #phpworld shows the execution path to the point where the code was paused Frames I… don’t have a cool drawing for “frames”…

Slide 23

Slide 23 text

legacy.joind.in/24817 @SammyK #phpworld & Environment Setup

Slide 24

Slide 24 text

legacy.joind.in/24817 @SammyK #phpworld

Slide 25

Slide 25 text

legacy.joind.in/24817 @SammyK #phpworld https://xdebug.org/docs/remote Debug client (DBGp protocol)

Slide 26

Slide 26 text

legacy.joind.in/24817 @SammyK #phpworld Setup

Slide 27

Slide 27 text

#1 Start listening to debugging connections

Slide 28

Slide 28 text

#2 Set a Breakpoint

Slide 29

Slide 29 text

legacy.joind.in/24817 @SammyK #phpworld Done!

Slide 30

Slide 30 text

legacy.joind.in/24817 @SammyK #phpworld Setup

Slide 31

Slide 31 text

configured installed installed

Slide 32

Slide 32 text

on Homebrew Install + $ brew install php $ pecl install xdebug

Slide 33

Slide 33 text

on APT Install + $ add-apt-repository -y \ ppa:ondrej/php $ apt-get update $ apt-get install php7.2-xdebug

Slide 34

Slide 34 text

https://xdebug.org/docs/install Install +

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

legacy.joind.in/24817 @SammyK #phpworld Configure

Slide 37

Slide 37 text

$ php --ini

Slide 38

Slide 38 text

$ php --ini

Slide 39

Slide 39 text

$ sudo vi /usr/local/etc/php/ 7.2/conf.d/ext-xdebug.ini

Slide 40

Slide 40 text

$ php -i | grep xdebug

Slide 41

Slide 41 text

legacy.joind.in/24817 @SammyK #phpworld Start a session or CLI

Slide 42

Slide 42 text

legacy.joind.in/24817 @SammyK #phpworld Query Param XDEBUG_SESSION_START

Slide 43

Slide 43 text

legacy.joind.in/24817 @SammyK #phpworld Cookie XDEBUG_SESSION

Slide 44

Slide 44 text

legacy.joind.in/24817 @SammyK #phpworld

Slide 45

Slide 45 text

legacy.joind.in/24817 @SammyK #phpworld

Slide 46

Slide 46 text

legacy.joind.in/24817 @SammyK #phpworld Env Variable export XDEBUG_CONFIG="idekey=foo" CLI

Slide 47

Slide 47 text

legacy.joind.in/24817 @SammyK #phpworld Env Variable set XDEBUG_CONFIG="idekey=foo" CLI

Slide 48

Slide 48 text

legacy.joind.in/24817 @SammyK #phpworld Don’t forget to unset set XDEBUG_CONFIG= unset XDEBUG_CONFIG when you’re done

Slide 49

Slide 49 text

legacy.joind.in/24817 @SammyK #phpworld alias debug-on='export XDEBUG_CONFIG="ide_key=foo"' alias debug-off='unset XDEBUG_CONFIG' Bash alias

Slide 50

Slide 50 text

legacy.joind.in/24817 @SammyK #phpworld Run some code! & CLI

Slide 51

Slide 51 text

legacy.joind.in/24817 @SammyK #phpworld PHP’s Built-in Web Server run locally using

Slide 52

Slide 52 text

legacy.joind.in/24817 @SammyK #phpworld Built right into the CLI SAPI! $ php -S 127.0.0.1:8888

Slide 53

Slide 53 text

legacy.joind.in/24817 @SammyK #phpworld

Slide 54

Slide 54 text

legacy.joind.in/24817 @SammyK #phpworld learn? What did we

Slide 55

Slide 55 text

legacy.joind.in/24817 @SammyK #phpworld +

Slide 56

Slide 56 text

legacy.joind.in/24817 @SammyK #phpworld

Slide 57

Slide 57 text

legacy.joind.in/24817 @SammyK #phpworld

Slide 58

Slide 58 text

legacy.joind.in/24817 @SammyK #phpworld CLI

Slide 59

Slide 59 text

legacy.joind.in/24817 @SammyK #phpworld Debugging In Action

Slide 60

Slide 60 text

legacy.joind.in/24817 @SammyK #phpworld

Slide 61

Slide 61 text

legacy.joind.in/24817 @SammyK #phpworld In production

Slide 62

Slide 62 text

But wait! * (see me after class for more info)

Slide 63

Slide 63 text

Sammy Kaye Powers Thanks! /24817 @SammyK SammyK.me Host of @PHPRoundtable legacy.