Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Debug Dance - An Intro To Step Debugging - Chicago PHP UG

The Debug Dance - An Intro To Step Debugging - Chicago PHP UG

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 Powers

March 27, 2017
Tweet

More Decks by Sammy Kaye Powers

Other Decks in Programming

Transcript

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

    View Slide

  2. Does not work for

    View Slide

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

    View Slide

  4. So you write
    Some Code

    View Slide

  5. Does not work

    View Slide

  6. You could check the
    Error logs

    View Slide

  7. All the things
    var_dump()

    View Slide

  8. View Slide

  9. OR

    View Slide

  10. Use a
    ‘er

    View Slide

  11. 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++)

    View Slide

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

    View Slide

  13. Some step-debugging
    Jargon

    View Slide

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

    View Slide

  15. run to the next breakpoint
    Resume Program

    View Slide

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

    View Slide

  17. run to the end of the current function
    Step Out

    View Slide

  18. advance to the next line in the same scope
    Step Over

    View Slide

  19. a live portal into the code execution process
    Debugging Console

    View Slide

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

    View Slide

  21. &
    Environment
    Setup

    View Slide

  22. Setup

    View Slide

  23. #1
    Start listening to
    debugging connections

    View Slide

  24. #2
    Set a
    Breakpoint

    View Slide

  25. Done!

    View Slide

  26. Setup

    View Slide

  27. configured
    installed
    installed

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  31. View Slide

  32. Configure

    View Slide

  33. $ php --ini

    View Slide

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

    View Slide

  35. $ php -i | grep xdebug

    View Slide

  36. Start a session
    or
    CLI

    View Slide

  37. Query Param
    XDEBUG_SESSION_START

    View Slide

  38. Cookie
    XDEBUG_SESSION

    View Slide

  39. View Slide

  40. View Slide

  41. View Slide

  42. Env Variable
    export XDEBUG_CONFIG="idekey=foo"
    CLI

    View Slide

  43. Env Variable
    set XDEBUG_CONFIG="idekey=foo"
    CLI

    View Slide

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

    View Slide

  45. Run some code!
    &
    CLI

    View Slide

  46. PHP’s Built-in
    Web Server
    run locally using

    View Slide

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

    View Slide

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

    View Slide

  49. View Slide