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
100
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
3
170
セッションのトークセッション / Traps for PHP session features in growing web apps
uzulla
2
110
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
5
2k
例外を投げるのをやめてみないか? あるいは受け入れてみないか? - How to use exceptions other than throwing
uzulla
4
900
PHPerが ISUCONでやるべき事
uzulla
1
840
開発生産性は上がらない - N Ways to Reduce Development Productivity
uzulla
1
220
test is not a job
uzulla
1
490
あなたのPHPアプリ、ログはでてますか?あるいはログをだしてますか? / Are you writing a log? Or just out a log?
uzulla
17
7.4k
Other Decks in Programming
See All in Programming
C++でシェーダを書く
fadis
6
4.1k
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
5
2.9k
みんなでプロポーザルを書いてみた
yuriko1211
0
290
Click-free releases & the making of a CLI app
oheyadam
2
120
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
360
Tauriでネイティブアプリを作りたい
tsucchinoko
0
380
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Better Code Design in PHP
afilina
PRO
0
130
React への依存を最小にするフロントエンド設計
takonda
19
5.1k
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
350
flutterkaigi_2024.pdf
kyoheig3
0
170
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Speed Design
sergeychernyshev
25
620
What's in a price? How to price your products and services
michaelherold
243
12k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Why Our Code Smells
bkeepers
PRO
334
57k
Site-Speed That Sticks
csswizardry
0
38
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
How STYLIGHT went responsive
nonsquared
95
5.2k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
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ʁ͏Μ…͕Μͬͯ… — ͬͱ׆༻ͯ͠ΨϯΨϯ͍ͬͯ͜͏ͳʂ — ࣭͋Γ·͔͢ʁ