Slide 1

Slide 1 text

Sammy Kaye Powers An Intro To Step Debugging in Dance The Chicago PHP UG March 27th, 2017

Slide 2

Slide 2 text

Does not work for

Slide 3

Slide 3 text

What is Debugging? Finding and fixing of unexpected behavior in code

Slide 4

Slide 4 text

So you write Some Code

Slide 5

Slide 5 text

Does not work

Slide 6

Slide 6 text

You could check the Error logs

Slide 7

Slide 7 text

All the things var_dump()

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

OR

Slide 10

Slide 10 text

Use a ‘er

Slide 11

Slide 11 text

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 12

Slide 12 text

…now is the perfect time to learn Step Debugging BNEW! Professional

Slide 13

Slide 13 text

Some step-debugging Jargon

Slide 14

Slide 14 text

a signal that tells the debugger to pause the execution of your code Breakpoint

Slide 15

Slide 15 text

run to the next breakpoint Resume Program

Slide 16

Slide 16 text

if the next line is a function call, enter the function Step Into

Slide 17

Slide 17 text

run to the end of the current function Step Out

Slide 18

Slide 18 text

advance to the next line in the same scope Step Over

Slide 19

Slide 19 text

a live portal into the code execution process Debugging Console

Slide 20

Slide 20 text

shows the execution path to the point where the code was paused Frames I… don’t have a cool drawing for “frames”…

Slide 21

Slide 21 text

& Environment Setup

Slide 22

Slide 22 text

Setup

Slide 23

Slide 23 text

#1 Start listening to debugging connections

Slide 24

Slide 24 text

#2 Set a Breakpoint

Slide 25

Slide 25 text

Done!

Slide 26

Slide 26 text

Setup

Slide 27

Slide 27 text

configured installed installed

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Configure

Slide 33

Slide 33 text

$ php --ini

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

$ php -i | grep xdebug

Slide 36

Slide 36 text

Start a session or CLI

Slide 37

Slide 37 text

Query Param XDEBUG_SESSION_START

Slide 38

Slide 38 text

Cookie XDEBUG_SESSION

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Env Variable export XDEBUG_CONFIG="idekey=foo" CLI

Slide 43

Slide 43 text

Env Variable set XDEBUG_CONFIG="idekey=foo" CLI

Slide 44

Slide 44 text

Don’t forget to unset set XDEBUG_CONFIG= unset XDEBUG_CONFIG when you’re done

Slide 45

Slide 45 text

Run some code! & CLI

Slide 46

Slide 46 text

PHP’s Built-in Web Server run locally using

Slide 47

Slide 47 text

Built right into the CLI SAPI! $ php -S 127.0.0.1:8888

Slide 48

Slide 48 text

But! if we have time, we’ll also use &

Slide 49

Slide 49 text

No content