This talk was presented at the Chicago PHP UG meetup on March 27th, 2017: https://www.meetup.com/Chicago-PHP-User-Group/events/237220317/
Sammy Kaye PowersAn Intro ToStep Debugging inDanceTheChicago PHP UGMarch 27th, 2017
View Slide
Does not work for
What isDebugging?Finding and fixing of unexpected behavior in code
So you writeSome Code
Does not work
You could check theError logs
All the thingsvar_dump()
OR
Use a‘er
Kate Gregory “ I'm not saying, ‘don'tuse printf()’, [...] butI think it's insane touse printf() on dayone of learning C++.[...] I would first sayuse the debugger.Episode 30: Stop Teaching C(When Teaching C++)
…now is the perfect time to learnStep DebuggingBNEW!Professional
Some step-debuggingJargon
a signal that tells the debugger to pause the execution of your codeBreakpoint
run to the next breakpointResume Program
if the next line is a function call, enter the functionStep Into
run to the end of the current functionStep Out
advance to the next line in the same scopeStep Over
a live portal into the code execution processDebugging Console
shows the execution path to the point where the code was pausedFramesI… don’t have a cool drawing for “frames”…
&EnvironmentSetup
Setup
#1Start listening todebugging connections
#2Set aBreakpoint
Done!
configuredinstalledinstalled
$ brew tap homebrew/homebrew-php$ brew install php71$ brew install php71-xdebugonHomebrewInstall +
$ add-apt-repository -y ppa:ondrej/php$ apt-get update$ apt-get install php7.1-xdebugonAPTInstall +
https://xdebug.org/docs/installInstall +
Configure
$ php --ini
$ sudo vi /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini
$ php -i | grep xdebug
Start a sessionorCLI
Query ParamXDEBUG_SESSION_START
CookieXDEBUG_SESSION
Env Variableexport XDEBUG_CONFIG="idekey=foo"CLI
Env Variableset XDEBUG_CONFIG="idekey=foo"CLI
Don’t forget to unsetset XDEBUG_CONFIG=unset XDEBUG_CONFIGwhen you’re done
Run some code!&CLI
PHP’s Built-inWeb Serverrun locally using
Built right into the CLI SAPI!$ php -S 127.0.0.1:8888
But!if we have time, we’ll also use&