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
Debug interactively PHP BLT #7
Search
Sota Sugiura
May 22, 2017
Technology
2
1.3k
Debug interactively PHP BLT #7
Sota Sugiura
May 22, 2017
Tweet
Share
More Decks by Sota Sugiura
See All by Sota Sugiura
内製したSlack Appで頑張るIncident Response@Waroom Meetup #1 / Incident Response with Slack App in 10X
sota1235
0
910
20220926_セキュリティチームの今_for_Drs._Prime_公開用.pdf
sota1235
0
60
再発防止策を考える技術 / #phpconsen
sota1235
10
3.6k
How to choose the best npm module for your team?
sota1235
9
520
Realtime Database for high traffic production application
sota1235
7
3.8k
Road to migrate JP Web as a microservice
sota1235
4
1.5k
インターフェース再入門 / Think Interface again
sota1235
6
10k
再発防止策を考える技術 #phpconfuk_rej
sota1235
1
1.1k
Update around Firebase #io18
sota1235
3
4.2k
Other Decks in Technology
See All in Technology
アプリをリリースできる状態に保ったまま 段階的にリファクタリングするための 戦略と戦術 / Strategies and tactics for incremental refactoring
yanzm
6
510
JEP 480: Structured Concurrency
aya_ebata
0
120
SAVEPOINT α版
savepoint
0
600
LandingZoneAccelerator と学ぶ 「スケーラブルで安全なマルチアカウントAWS環境」と 私たちにもできるベストプラクティス
maimyyym
1
120
より快適なエラーログ監視を目指して
leveragestech
3
1k
「自動テストのプラクティスを効果的に学ぶためのカードゲーム」 ( #sqip2024 )
teyamagu
PRO
0
110
EitherT_with_Future
aoiroaoino
1
990
ビジネスとエンジニアリングを繋ぐプロダクトを中心とした組織づくりの実践
sansantech
PRO
1
150
効果的なオンコール対応と障害対応
ryuichi1208
5
2.5k
スタッフエンジニアの道: The Staff Engineer’s Path
snoozer05
PRO
32
11k
難しいから面白い!医薬品×在庫管理ドメインの複雑性と向き合い、プロダクトの成長を支えるための取り組み / Initiatives to Support Product Growth
kakehashi
2
170
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
9
41k
Featured
See All Featured
How GitHub Uses GitHub to Build GitHub
holman
472
290k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
88
16k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
27
7.4k
Statistics for Hackers
jakevdp
793
220k
5 minutes of I Can Smell Your CMS
philhawksworth
201
19k
Designing for humans not robots
tammielis
248
25k
[RailsConf 2023] Rails as a piece of cake
palkan
46
4.6k
Designing for Performance
lara
604
68k
Building Adaptive Systems
keathley
36
2.1k
Documentation Writing (for coders)
carmenintech
65
4.3k
Code Reviewing Like a Champion
maltzj
518
39k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
24
590
Transcript
Debug interactively @sota1235
var_dump($sota1235); • @sota1235 • Call me ‘kirin’ • PHP &
JavaScript • Mercari, Inc.
http://sota1235.hatenablog.com/entry/2017/01/01/175228
I did it
Today’s theme
Debug
Debugging method • Using var_dump, echo • php -a •
Writing tests • IDE • etc…
Debugging method • Using var_dump, echo • php -a •
Writing tests • IDE • etc…
Using REPL (php -a) • Easy to use • Can
load files • Good integration with CLI
Is it the best way? • Bother to require autoloader
• Reset state every time • Not good for many autoloader files…
None
psysh http://psysh.org/
psysh • Rich CLI • Customizable • We can make
own REPL
Rich REPL • Auto complete (with Tab key) • Useful
commands • history, documentation, show properties • Rich UI
Customizable • We can place config file • ~/.config/psysh/psysh.php •
We can do anything if PHP can
<?php // Automatically autoload Composer dependencies if (is_file(getcwd() . '/vendor/autoload.php'))
{ require_once(getcwd() . '/vendor/autoload.php'); } Load composer automatically
<?php // Use local config, if available if (is_file(getcwd() .
'/.psysh.php')) { return require(getcwd() . '/.psysh.php'); } // Fall back to global config return [ 'startupMessage' => '<info>Using global config</info>', 'commands' => [ new \Psy\Command\ParseCommand, ], ]; Load local config
<?php $default_includes = []; // Automatically autoload Composer dependencies if
(is_file(getcwd() . '/vendor/autoload.php')) { $default_includes[] = getcwd() . '/vendor/autoload.php'); } if (array_pop(explode('/', getcwd())) === '') { $default_includes[] = getcwd() . 'lecacy_autoloader.php'; } return [ 'defaultIncludes' = $default_includes, ]; Legacy project? No problem☺
Thank you