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
180
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
More Context, Better Code. 既存コードやOAS等をコンテキストとしてLLMに与える事で、よりよいコード生成を行う話
uzulla
1
99
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
3
170
セッションのトークセッション / Traps for PHP session features in growing web apps
uzulla
2
110
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
5
1.9k
例外を投げるのをやめてみないか? あるいは受け入れてみないか? - How to use exceptions other than throwing
uzulla
4
890
PHPerが ISUCONでやるべき事
uzulla
1
830
開発生産性は上がらない - N Ways to Reduce Development Productivity
uzulla
1
220
test is not a job
uzulla
1
480
あなたのPHPアプリ、ログはでてますか?あるいはログをだしてますか? / Are you writing a log? Or just out a log?
uzulla
17
7.4k
Other Decks in Programming
See All in Programming
Quine, Polyglot, 良いコード
qnighy
4
640
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
CSC509 Lecture 12
javiergs
PRO
0
160
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
Realtime API 入門
riofujimon
0
150
距離関数を極める! / SESSIONS 2024
gam0022
0
280
as(型アサーション)を書く前にできること
marokanatani
9
2.6k
最新TCAキャッチアップ
0si43
0
140
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
910
Featured
See All Featured
RailsConf 2023
tenderlove
29
900
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Six Lessons from altMBA
skipperchong
27
3.5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Become a Pro
speakerdeck
PRO
25
5k
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ʁ͏Μ…͕Μͬͯ… — ͬͱ׆༻ͯ͠ΨϯΨϯ͍ͬͯ͜͏ͳʂ — ࣭͋Γ·͔͢ʁ