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

May the PHP dev be with xdebug

uzulla
June 22, 2023

May the PHP dev be with xdebug

- 【非公式】PHPカンファレンス福岡全然野菜
- 2023/06/22
- uzulla

uzulla

June 22, 2023
Tweet

More Decks by uzulla

Other Decks in Programming

Transcript

  1. ࠷ॳʹɺࡢࠓ(ver 3)ΠνΦγͷػೳ — ʮxdebugͷϩάʯʮ͑ͬʯ — ͪΐͬͱલ·Ͱɺxdebug͕ʮͳΜͰ͏͔͝ͳ͍ͷ͔ʯௐ΂Δͷେมͩͬͨ — xdebugͷϓϩ(ʁ)͕Τεύʔ͢Δ͜ͱ͕ଟ͔ͬͨ — ࠓ͸ৄࡉͳϩά͕ग़ͤΔͷͰࣗݾղָܾ͕ʑʂʂʂ

    # in php.ini (PHP_INI_SYSTEM) xdebug.log_level = 10 xdebug.log = /tmp/xdebug.log # ࠓճͷαϯϓϧɺҎԼʹ͋Γ·͢ # https://github.com/uzulla/phpconfuk2023-zenzenyasai-demo-code
  2. ྫɺConfig͕ݹ͍ͱ͔ [20] [Config] CRIT:The setting 'xdebug.remote_host' has been renamed, see

    the upgrading guide at https://xdebug.org/docs/ upgrade_guide#changed-xdebug.remote_host
  3. ྫɺ઀ଓͰ͖ͳ͍ͱ͔ [16] [Step Debug] INFO: Connecting to configured address/port: localhost:9003.

    [16] [Step Debug] WARN: Creating socket for 'localhost:9003', poll success, but error: Operation now in progress (29). [16] [Step Debug] WARN: Creating socket for 'localhost:9003', connect: Cannot assign requested address. [16] [Step Debug] ERR: Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port).
  4. ϩά͸Ғେ — ͳΜ͔ಈ͔ͳ͍࣌͸͜ΕΛΈΖɺશ෦͜͜ʹ͋Δ — σόοΨ͕PhpStormͱ͔ʹͭͳ͕Βͳ͍ͷ͕Ұ൪೉͍ͬͯ͠ΈΜͳݴͬͯΔ͠… — ͦͷଞɺ௨৴಺༰ΛΈΔͱඇৗʹଟ͘ͷ৘ใ͕ಘΒΕ·͢ʂ ... [18] [Step

    Debug] <- step_into -i 10 [18] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="10" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/index.php" lineno="18"></xdebug:message> </response> ... [18] [Step Debug] <- breakpoint_set -i 16 -t line -f file:///var/www/html/index.php -n 25
  5. ͳΜͰ΋Ͱ͖Δ — ม਺ͷ্ॻ͖ͱ͔͕Ͱ͖Δ — Ϋϥεͱ͔ͷϩʔυ΋Ͱ͖Δ — PDOͷ৐ͬऔΓͱ͔΋Ͱ͖Δ — ϑΝΠϧͷಡΈॻ͖΋Ͱ͖Δ —

    ϦΫΤετσʔλͷμϯϓɺϩʔυͱ͔ — ೔෇ͳͲͷվม — ͳΜͳΒɺ͜͜Ͱrequire_once͔Β શ෦ͷίʔυ Λॻ͍ͯΈΔ͜ͱ΋Ͱ͖Δ — (ͨͩɺGOTO͸͔ͭ͑ͳ͍ΜͩΑͶɺ࣍ͷߦΛʮεΩοϓʯͱ͔Ͱ͖ΔͱָͳΜ͚ͩ Ͳɻ·͋ifจͰ͘͘Ε͹Ͱ͖ͳ͍͜ͱ͸ͳ͍)
  6. ͦͷ΄͔ — ϓϩϑΝΠϥ…͸ɺseike͞Μͱ͔͕ྑ͍هࣄΛ͔͍͍ͯΔͷͰ — https://tech.fusic.co.jp/posts/2020-12-14-php8-xdebug-webgrind/ — coverageɺtrace΋ͨͷ͍͚͠Ͳɺࠓ೔͸লུ — DBGp Proxy

    Tool ΋ศར΍Ͱ — This tool allows you to proxy and route debugging request to IDEs depending on which IDE key is in use. — stgαʔόʔͱ͔ʮෳ਺ਓͰ৮ΔαʔόʔʯͰ΋xdebug࢖͏࣌ʹͲ͏ͧ — https://xdebug.org/docs/dbgpProxy
  7. ·ͱΊ — ॻ͖׵͑ͯϦϩʔυ஍ࠈͱ͔ෆศ͗͢Δ… xdebugͷEvalͰॎԣແਚ͠Α͏ͥʂ — ʮ͜ͷIFͷcondͲ͏͢Ε͹͍͍͔ͳʯͱ͔ͷࢼߦࡨޡ͕ແݶʹͰ͖Δ — PHP͸ಈతݴޠͳͷͰɺevalͰ͖ͯศརʂ — (PsySHͱ͔΋͋Δ͚ͲɺPhpStorm+xdebugͷ΄͏͕΍ͬͺΓศརɺิ׬͋Δ͠)

    — ެࣜαΠτ΋ͦ͏͕ͩɺ࡞ऀͷYoutube΋ඞݟ — (όʔδϣϯʹΑͬͯػೳ͕;͑ͨΓɺมΘͬͨΓ͢Δͷ͸஫ҙ) — PhpStormͩͱUI΋Α͘Ͱ͖ͯ·͢Ͷʂ…͑ͬVSCʁ͏Μ…͕Μ͹ͬͯ… — ΋ͬͱ׆༻ͯ͠ΨϯΨϯ΍͍ͬͯ͜͏ͳʂ — ࣭໰͋Γ·͔͢ʁ