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
110
More Context, Better Code. 既存コードやOAS等をコンテキストとしてLLMに与える事で、よりよいコード生成を行う話
uzulla
1
110
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
3
170
セッションのトークセッション / 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
920
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
Djangoの開発環境で工夫したこと - pre-commit / DevContainer
hiroki_yod
1
690
42 best practices for Symfony, a decade later
tucksaun
1
150
WebAssembly Unleashed: Powering Server-Side Applications
chrisft25
0
2.1k
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.7k
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
11
4.1k
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
730
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
1
2k
Testing Assembly: Code or Low Code - Navigating the Test Automation Options
maaretp
0
100
layerx_20241129.pdf
kyoheig3
2
260
たのしいparse.y
ydah
3
120
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
180
Cursorでアプリケーションの追加開発や保守をどこまでできるか試したら得るものが多かった話
drumnistnakano
0
290
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
790
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Faster Mobile Websites
deanohume
305
30k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Statistics for Hackers
jakevdp
796
220k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Thoughts on Productivity
jonyablonski
67
4.3k
Designing for Performance
lara
604
68k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Facilitating Awesome Meetings
lara
50
6.1k
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ʁ͏Μ…͕Μͬͯ… — ͬͱ׆༻ͯ͠ΨϯΨϯ͍ͬͯ͜͏ͳʂ — ࣭͋Γ·͔͢ʁ