Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
May the PHP dev be with xdebug
Search
uzulla
June 22, 2023
Programming
0
190
May the PHP dev be with xdebug
- 【非公式】PHPカンファレンス福岡全然野菜
- 2023/06/22
- uzulla
uzulla
June 22, 2023
Tweet
Share
More Decks by uzulla
See All by uzulla
似たもの同士のPerlとPHP
uzulla
1
130
More Context, Better Code. 既存コードやOAS等をコンテキストとしてLLMに与える事で、よりよいコード生成を行う話
uzulla
1
110
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
3
180
セッションのトークセッション / Traps for PHP session features in growing web apps
uzulla
2
120
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
5
2k
例外を投げるのをやめてみないか? あるいは受け入れてみないか? - How to use exceptions other than throwing
uzulla
4
930
PHPerが ISUCONでやるべき事
uzulla
1
1k
開発生産性は上がらない - N Ways to Reduce Development Productivity
uzulla
1
240
test is not a job
uzulla
1
500
Other Decks in Programming
See All in Programming
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
630
103 Early Hints
sugi_0000
1
220
42 best practices for Symfony, a decade later
tucksaun
1
180
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
180
Haze - Real time background blurring
chrisbanes
1
500
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
240
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
170
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
9k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
Side Projects
sachag
452
42k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
The Invisible Side of Design
smashingmag
298
50k
Navigating Team Friction
lara
183
15k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
GitHub's CSS Performance
jonrohan
1030
460k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Building an army of robots
kneath
302
44k
Music & Morning Musume
bryan
46
6.2k
Transcript
May the PHP dev be with xdebug — ʲඇެࣜʳPHPΧϯϑΝϨϯεԬશવࡊ —
2023/06/22 — uzulla
None
None
None
ࣗݾհ — uzulla — ྲྀ͠ͷPHPer — ࠓMBPͷέʔϒϧ͕ম͚·͕ͨ͠ަͰ͖·ͨ͠
xdebug͔ͭͬͯ·͔͢ʁ — ʮ͔ͭͬͯΔΑɺεςοϓ࣮ߦͱ͔Break pointͰ͠ΐʁʯ — ʮͳΜ͔var_dump͕खʹͳΔΑͶʯ — ʮઃఆ໘͔ͩΒPrint debugͯ͠·͢ʯ
࠷ॳʹɺࡢࠓ(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
ྫɺ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
ྫɺଓͰ͖ͳ͍ͱ͔ [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).
ϩάҒେ — ͳΜ͔ಈ͔ͳ͍࣌͜ΕΛΈΖɺશ෦͜͜ʹ͋Δ — σόοΨ͕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
xdebug_info() — Τεύʔճආʹ༗༻ — ʮͳʹ͕Enableͳͷ͔ʯ — ʮͲ͜ʹͭͳ͗ʹ͍ͬͯΔͷ͔ʯ — ʮͲ͏͍͏Ϟʔυͳͷ͔ʯ —
Λ͠ΒΔͷ͕͛͢ʔָʹ… — DocͷϦϯΫ͋Δ
ͯ͞ɺࠓճհ͢Δ໘നػೳ eval — ਖ਼໊ࣜশ͠Βͳ͍ — evalͰ͖Δ — ʮͲ͜ͰͰʯ
DEMO — PhpStorm+xdebug — σόοΨͰܭࢉػΛ͓ͯ͠৭ʑͰ͖Δ
ͳΜͰͰ͖Δ — มͷ্ॻ͖ͱ͔͕Ͱ͖Δ — Ϋϥεͱ͔ͷϩʔυͰ͖Δ — PDOͷͬऔΓͱ͔Ͱ͖Δ — ϑΝΠϧͷಡΈॻ͖Ͱ͖Δ —
ϦΫΤετσʔλͷμϯϓɺϩʔυͱ͔ — ͳͲͷվม — ͳΜͳΒɺ͜͜Ͱrequire_once͔Β શ෦ͷίʔυ Λॻ͍ͯΈΔ͜ͱͰ͖Δ — (ͨͩɺGOTO͔ͭ͑ͳ͍ΜͩΑͶɺ࣍ͷߦΛʮεΩοϓʯͱ͔Ͱ͖ΔͱָͳΜ͚ͩ Ͳɻ·͋ifจͰ͘͘ΕͰ͖ͳ͍͜ͱͳ͍)
Ͳ͏ͯ͠ϩάΛݟͨ͘ͳ͍ਓ͜͜ͰΈΕͯศརͰ͢Ͷʂʂʂ
͋ʔɺಥવ͘NoticeͰBreak͍ͨ͠ΑͶɺͲ͏͠Α͏… ͋ͱFatalͱ͔ͰऔΓ͍ͨΑͶ…
ͬͯ࣌ʹɺϓϩͷPHPer(ʁ)ͳΒϋϯυϥΛ͍ΕΔΑͶʂ
(ͪΐͬͱͨܽ͠ɺ͜͜ͷը໘Ͱิ͖͚͘ͲɺίʔυδϟϯϓͰ͖ͳ͍)
ʮධՁ͖Break point͏͔͝ͳ͍ͳ…ʯ͔Βͷʮೖͯ͠ΔΜ͚ʂʂʯ(͋Δ͋Δ)
tips(?): ެࣜͷDocΛΈΖ — ͨΓલ͗͢Δ͕ɺ͋ΒΏΔใެ͕ࣜਖ਼͍͠ — ͱ͍͏͔ɺάάΔͱग़ͯ͘Δใxdebug2ͷใ͕ଟ͍ — 2->3Ͱ͔ͳΓมΘͬͨˍΈΜͳखบͰͬͯΔˍൿͷλϨͰɺ݁ߏϋνϟϝνϟ — ΑΈͳΕ
— ެࣜͷYoutubeඞݟ — https://www.youtube.com/@DerickRethansXdebug/playlists
ͦͷ΄͔ — ϓϩϑΝΠϥ…ɺ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
·ͱΊ — ॻ͖͑ͯϦϩʔυࠈͱ͔ෆศ͗͢Δ… xdebugͷEvalͰॎԣແਚ͠Α͏ͥʂ — ʮ͜ͷIFͷcondͲ͏͢Ε͍͍͔ͳʯͱ͔ͷࢼߦࡨޡ͕ແݶʹͰ͖Δ — PHPಈతݴޠͳͷͰɺevalͰ͖ͯศརʂ — (PsySHͱ͔͋Δ͚ͲɺPhpStorm+xdebugͷ΄͏͕ͬͺΓศརɺิ͋Δ͠)
— ެࣜαΠτͦ͏͕ͩɺ࡞ऀͷYoutubeඞݟ — (όʔδϣϯʹΑͬͯػೳ͕;͑ͨΓɺมΘͬͨΓ͢Δͷҙ) — PhpStormͩͱUIΑ͘Ͱ͖ͯ·͢Ͷʂ…͑ͬVSCʁ͏Μ…͕Μͬͯ… — ͬͱ׆༻ͯ͠ΨϯΨϯ͍ͬͯ͜͏ͳʂ — ࣭͋Γ·͔͢ʁ