Slide 1

Slide 1 text

joind.in/talk/a2b9a @SammyK #phptek Sammy Kaye Powers Dance The May 26th, 2017 PHP[TEK] 2017 An Intro To Step Debugging in

Slide 2

Slide 2 text

Thanks to our Sponsors!

Slide 3

Slide 3 text

joind.in/talk/a2b9a @SammyK #phptek Download the examples & slides joind.in/talk/a2b9a

Slide 4

Slide 4 text

joind.in/talk/a2b9a @SammyK #phptek Does not work for

Slide 5

Slide 5 text

joind.in/talk/a2b9a @SammyK #phptek What is Debugging? Finding and fixing unexpected behavior in code

Slide 6

Slide 6 text

So you write Some Code

Slide 7

Slide 7 text

Does not work

Slide 8

Slide 8 text

joind.in/talk/a2b9a @SammyK #phptek You could check the Error logs

Slide 9

Slide 9 text

joind.in/talk/a2b9a @SammyK #phptek All the things var_dump()

Slide 10

Slide 10 text

joind.in/talk/a2b9a @SammyK #phptek

Slide 11

Slide 11 text

joind.in/talk/a2b9a @SammyK #phptek OR

Slide 12

Slide 12 text

joind.in/talk/a2b9a @SammyK #phptek Use a ‘er

Slide 13

Slide 13 text

joind.in/talk/a2b9a @SammyK #phptek 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 14

Slide 14 text

joind.in/talk/a2b9a @SammyK #phptek …now is the perfect time to learn Step Debugging BNEW! Professional

Slide 15

Slide 15 text

joind.in/talk/a2b9a @SammyK #phptek Some step-debugging Jargon

Slide 16

Slide 16 text

joind.in/talk/a2b9a @SammyK #phptek a signal that tells the debugger to pause the execution of your code Breakpoint

Slide 17

Slide 17 text

joind.in/talk/a2b9a @SammyK #phptek run to the next breakpoint Resume Program

Slide 18

Slide 18 text

joind.in/talk/a2b9a @SammyK #phptek advance to the next line in the same scope Step Over

Slide 19

Slide 19 text

joind.in/talk/a2b9a @SammyK #phptek if the next line is a function call, enter the function Step Into

Slide 20

Slide 20 text

joind.in/talk/a2b9a @SammyK #phptek run to the end of the current function Step Out

Slide 21

Slide 21 text

joind.in/talk/a2b9a @SammyK #phptek a live portal into the code execution process Debugging Console

Slide 22

Slide 22 text

joind.in/talk/a2b9a @SammyK #phptek 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

joind.in/talk/a2b9a @SammyK #phptek & Environment Setup

Slide 24

Slide 24 text

joind.in/talk/a2b9a @SammyK #phptek Setup

Slide 25

Slide 25 text

#1 Start listening to debugging connections

Slide 26

Slide 26 text

#2 Set a Breakpoint

Slide 27

Slide 27 text

joind.in/talk/a2b9a @SammyK #phptek Done!

Slide 28

Slide 28 text

joind.in/talk/a2b9a @SammyK #phptek Setup

Slide 29

Slide 29 text

configured installed installed

Slide 30

Slide 30 text

$ brew tap homebrew/homebrew-php $ brew install php71 $ brew install php71-xdebug on Homebrew Install +

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

joind.in/talk/a2b9a @SammyK #phptek Configure

Slide 35

Slide 35 text

$ php --ini

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

$ php -i | grep xdebug

Slide 38

Slide 38 text

joind.in/talk/a2b9a @SammyK #phptek Start a session or CLI

Slide 39

Slide 39 text

joind.in/talk/a2b9a @SammyK #phptek Query Param XDEBUG_SESSION_START

Slide 40

Slide 40 text

joind.in/talk/a2b9a @SammyK #phptek Cookie XDEBUG_SESSION

Slide 41

Slide 41 text

joind.in/talk/a2b9a @SammyK #phptek

Slide 42

Slide 42 text

joind.in/talk/a2b9a @SammyK #phptek

Slide 43

Slide 43 text

joind.in/talk/a2b9a @SammyK #phptek Env Variable export XDEBUG_CONFIG="idekey=foo" CLI

Slide 44

Slide 44 text

joind.in/talk/a2b9a @SammyK #phptek Env Variable set XDEBUG_CONFIG="idekey=foo" CLI

Slide 45

Slide 45 text

joind.in/talk/a2b9a @SammyK #phptek Don’t forget to unset set XDEBUG_CONFIG= unset XDEBUG_CONFIG when you’re done

Slide 46

Slide 46 text

joind.in/talk/a2b9a @SammyK #phptek Run some code! & CLI

Slide 47

Slide 47 text

joind.in/talk/a2b9a @SammyK #phptek PHP’s Built-in Web Server run locally using

Slide 48

Slide 48 text

joind.in/talk/a2b9a @SammyK #phptek Built right into the CLI SAPI! $ php -S 127.0.0.1:8888

Slide 49

Slide 49 text

joind.in/talk/a2b9a @SammyK #phptek

Slide 50

Slide 50 text

joind.in/talk/a2b9a @SammyK #phptek learn? What did we

Slide 51

Slide 51 text

joind.in/talk/a2b9a @SammyK #phptek +

Slide 52

Slide 52 text

joind.in/talk/a2b9a @SammyK #phptek

Slide 53

Slide 53 text

joind.in/talk/a2b9a @SammyK #phptek

Slide 54

Slide 54 text

joind.in/talk/a2b9a @SammyK #phptek CLI

Slide 55

Slide 55 text

joind.in/talk/a2b9a @SammyK #phptek Debugging In Action

Slide 56

Slide 56 text

joind.in/talk/a2b9a @SammyK #phptek

Slide 57

Slide 57 text

joind.in/talk/a2b9a @SammyK #phptek In production

Slide 58

Slide 58 text

But wait! I have examples of other setups! & * (see me after class for more info)

Slide 59

Slide 59 text

THANKS! SAMMY KAYE POWERS @SammyK SammyK.me Host of @PHPRoundtable @ChiPHPUG West Coast Swing Hire me! :) /talk/a2b9a I have stickers!