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
940
PHPerが ISUCONでやるべき事
uzulla
1
1k
開発生産性は上がらない - N Ways to Reduce Development Productivity
uzulla
1
250
test is not a job
uzulla
1
500
Other Decks in Programming
See All in Programming
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
360
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
160
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
130
Spatial Rendering for Apple Vision Pro
warrenm
0
150
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
770
Beyond ORM
77web
9
1.2k
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
8
1.9k
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
230
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
720
Zoneless Testing
rainerhahnekamp
0
120
Featured
See All Featured
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Gamification - CAS2011
davidbonilla
80
5.1k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.3k
Building Applications with DynamoDB
mza
91
6.1k
Code Review Best Practice
trishagee
65
17k
Into the Great Unknown - MozCon
thekraken
34
1.5k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Code Reviewing Like a Champion
maltzj
521
39k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
How GitHub (no longer) Works
holman
311
140k
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ʁ͏Μ…͕Μͬͯ… — ͬͱ׆༻ͯ͠ΨϯΨϯ͍ͬͯ͜͏ͳʂ — ࣭͋Γ·͔͢ʁ