Xdebug Debugger and Profiler Tool -PHPæ¡åŒµã ãµãŒããŒãžã®ã€ã³ã¹ããŒã«ãšèšå®ãå¿ èŠã§ãã 衚瀺å¯èœïŒé¢æ°åŒã³åºãã¹ã¿ãã¯ãã¡ã¢ãªå²ãåœãŠã æ©èœïŒãããã¡ã€ãªã³ã°ãã³ãŒãã«ãã¬ããžåæãç¡éååž°ã«å¯Ÿããä¿è·ãã€ã³ã¿ã©ã¯ãã£ããªã¹ã¯ãªãããããã°ã Xdebugãã°èŠèŠåãœãããŠã§ã¢ïŒ Webgrind -Xdebugããããã¡ã€ãªã³ã°ããããã®WebããŒã¹ã®ã€ã³ã¿ãŒãã§ã€ã¹ãPHPã§èšè¿°ãããMacGDBp -Xdebugã䜿çšããŠPHPã¢ããªã±ãŒã·ã§ã³ããããã°ã§ããMac OS Xã¯ã©ã€ã¢ã³ãã Linux GUI kcachegrind ã ç¡æã§ãã å€ãã®IDEãšçµ±åããŸãã xdebugã䜿çšããPHPã¢ããªã±ãŒã·ã§ã³ã®ãããã¡ã€ãªã³ã°ãåç §ããŠãã ããã php.iniã§ãªãã·ã§ã³ãæå¹ã«ãããšïŒ
html_errors = On
var_dumpïŒïŒã®åºåãšãšã©ãŒã¡ãã»ãŒãžããã©ãŒãããããŸãã
Xhprofã¯ãfacebookã®PHPæ¡åŒµæ©èœã§ãã ãµãŒããŒãžã®ã€ã³ã¹ããŒã«ãšèšå®ãå¿ èŠã§ãã åé¢æ°ã®å®è¡æéãã¡ã¢ãªäœ¿çšéãã¬ã€ãã³ã·ãåŒã³åºãæ°ãªã©ãåéã§ããŸãã ãã®æ¡åŒµæ©èœã¯ãPECLãªããžããªããå ¥æã§ããŸã ã ãã¡ãã®ããã¥ã¡ã³ããã芧ãã ãã[tyts] ã ãŸããxhprofãšFirePHPã䜿çšããŠãPHPã¢ããªã±ãŒã·ã§ã³ã®ãããã¡ã€ãªã³ã°ãšãããã°ãè¡ããŸã ã å©ç¹ã®ãã¡ãã·ã¹ãã ã«ããŸãè² è·ããããªãã®ã§ãæŠéã«ãããããšãã§ããŸãã ç¡æã§ãã
DBG ïŒPHPãããã¬ãŒãšãããã¡ã€ã©ãŒïŒ-PHPæ¡åŒµã ãµãŒããŒãžã®ã€ã³ã¹ããŒã«ãšèšå®ãå¿ èŠã§ãã IDEãŸãã¯ã³ã³ãœãŒã«ããããã¹ããµãŒããŒãå®çšŒåãµãŒããŒã§äœæ¥ããããŒã«ã«ãŸãã¯ãªã¢ãŒãã§ã¹ã¯ãªããããããã°ã§ããŸãã ææ/ç¡æçã
ZendDebug -PHPæ¡åŒµãZend Studioã®äžéšïŒææIDEïŒã ãµãŒããŒãžã®ã€ã³ã¹ããŒã«ãšèšå®ãå¿ èŠã§ãã ããã«ãããxdebugãZend Studioã®GUIããŸãã¯Zend Server IDEãšã»ãŒåãããšãå¯èœã«ãªããŸãã ææã 以äžã§è©³çŽ°ã«æ€èšããŸãã
Memtrackã¯PHPã®æ¡åŒµæ©èœã§ãã ã¡ã¢ãªãªãŒã¯ãæ€çŽ¢ã§ããŸãã Crownã«ãã£ãŠããŸãã¯ããŒã¢ã³ãšããŠå®è¡ãããã¹ã¯ãªããã確èªãããšäŸ¿å©ã§ãã ç¡æã§ãã [tyts]ãåç §
APD Advanced PHPãããã¬ãŒã¯PHPæ¡åŒµã§ãã xdebugãšã®ç«¶åã¯åŒ±ãã§ãããmemtrackæ©èœããããŸãã IDEãšã®çµ±åã¯äžååã§ãããã³ã³ãœãŒã«ã€ã³ã¿ãŒãã§ã€ã¹ããããŸãïŒ[ tyts ]ãåç §ïŒã ç¡æã§ãã
DTrace + PHPã¯PHPæ¡åŒµæ©èœã§ãã äœã¬ãã«ã®ãããã°ã [tyts]ãåç §ããŠãã ããã Straceããã®ä»ã®ã·ã¹ãã ãããã¬ãŒã®ååšãå¿ããªãã§ãã ããããããã¯ãããã°ãç¬ãæŽèµ°ãããå Žæã瀺ãããšãã§ããŸãã äŸãã°
strace -p 1111
ã·ã¹ãã ã³ãŒã«ã¹ã¯ãªããã®åæãPID = 1111ã ãããã¯ãŒã¯ã¢ãã©ã€ã¶ãŒwireshark ïŒWindowsïŒã ngrep ã tcpdump ïŒLinuxïŒ-ãããã¯ãŒã¯ãã©ãã£ãã¯ããããã³ã«ãªã©ã®åæçš
FirePHP -phpã§èšè¿°ãããã¯ã©ã¹+ FireFoxã®æ¡åŒµã phpã¡ãœãããåŒã³åºãããšã«ããããããã°ã¡ãã»ãŒãžãFirebugã³ã³ãœãŒã«ã«éä¿¡ã§ããŸãã ãã¹ãŠã®æ å ±ã¯X-FirePHP-Dataã®ããããŒãä»ããŠéä¿¡ããããããããŒãžã®ã¡ã€ã³ã³ã³ãã³ããšéè€ããŸããã ç¡æã§ãã Firebugã䜿çšããPHPã®ãããã°ãåç §ããŠãã ãã
php-console -Google Chromeã®php +æ¡åŒµã§æžãããŠããŸãã Google Chromeå°çšã®FirePHPã«é¡äŒŒããŠããŸãããæ©èœã¯å€å°ç°ãªããŸãã ç¡æã§ãã php-consoleãåç §ããŠãã ãã
phpã§èšè¿°ãããPHP_Debugã¯ã©ã¹ã PHPã³ãŒãã®ãããã°ã«åœ¹ç«ã¡ãã¹ã¯ãªããã®å®è¡ãã¹ã衚瀺ãããã¹ãŠã®å€æ°ãã©ã³ã¿ã€ã ãã€ã³ã¯ã«ãŒããã¡ã€ã«ãå®è¡ãããã¯ãšãªãå€æ°ãç£èŠããŸã...ãã®æ å ±ã¯ã¹ã¯ãªããã®å®è¡äžã«åéããããã®æåŸã«è¡šç€ºããããã€ã§ã䜿çšã§ããŸãã ç¡æã§ãã
ãã³ãã¯ããªã¢ã«ã¿ã€ã ã®ç£èŠããã³çµ±èšãµãŒãã¹ã§ãã èŠã
PHPããªã¢ã«ã¿ã€ã ã§ç£èŠããŸã
Pinbaã䜿çšããŠPHPã³ãŒãã®ããã©ãŒãã³ã¹ãç£èŠããŸã ã ç¡æ
äžè¬çãªèšäºïŒ
PHPãããã¡ã€ãªã³ã°
è€éãªWebã¢ããªã±ãŒã·ã§ã³ã®ãããã°-éçšãµãŒããŒã§ã®å¹æçãªãã°ã¯ã©ãã·ã£ãŒ
ææ°ã®CMS / CMF / Frameworkã®ãããã¬ãŒ ã ç§ãã¡ã¯ããããèæ ®ããŸããããªããªã å€ãã®å Žåããããã¯ç¹å®ã®ãã®ã§ãããç¹å®ã®ã·ã§ã«çšã«èšèšãããŠãããããå€éšã§äœ¿çšãããïŒIDEïŒãèšèšãå€§å¹ ã«å€æŽããã«é©çšãããããããšã¯ã§ããŸããã
ã¢ããªã±ãŒã·ã§ã³ã®ããã«ããã¯ãåéããŠåæããã«ã¯ãsyslogéäžã¹ãã¬ãŒãžæè¡ã圹ç«ã€å ŽåããããŸãã[ tyts ]ãåç §ããŠãã ããã
ZendDebugã«æ»ããŸãã ç§ã¯äž»ã«Zend Studioã䜿çšããŠãããããããã䜿çšããã®ãæã䟿å©ã§ãã ããã«ãããã¹ã¯ãªããã®é²è¡ç¶æ³ãããã«ç解ã§ããIDEããã®ã³ãŒãã®ããã²ãŒã·ã§ã³ããµããŒããããŸãã IDE以å€ã®ãµãŒãããŒãã£ããŒã«ã¯å¿ èŠãããŸããã äžåºŠã»ããã¢ããããŠäœ¿çšããã®ã§ããšãŠã䟿å©ã§ãã
Zend Studioã§ã®ã¹ã¯ãªããã®ãããã°ãšãããã¡ã€ãªã³ã°ã¯ãxdebugãŸãã¯ZendDebugã䜿çšããŠå°ãªããšã2ã€ã®æ¹æ³ã§å¯èœã§ãã xdebugã䜿çšããŠãµã€ãããããã¡ã€ãªã³ã°ããã®ã¯ãä»ã§ã¯ããŸããããŸããã§ãããããã¯äžå¯èœã§ããããããã°ã®ã¿ã§ãã
ããŒã«ã«ã³ãŒãã®ãããã°ã«ã€ããŠã¯ãZend Studio 5.5 [tyts]ã®æ代ã«æžãæ»ãããŸããã ãã以æ¥ãã»ãšãã©å€ãã£ãŠããŸããã ããããWebãµãŒããŒãšãããã°ã³ãŒãããªã¢ãŒããµãŒããŒã«ããå Žåãåé¡ãçºçããŸããã å€ãã®å Žåããã®ãããªãµã³ãããã¯ã¹ã¯å€éšããéããããäœæ¥ã«å¿ èŠãªããŒãã®ã¿ãéãããŸãã ãã ããSSHãä»ããŠãã®ãããªãµã³ãããã¯ã¹ã«ã¢ã¯ã»ã¹ã§ããå Žåããã¡ã€ã¢ãŠã©ãŒã«ã®æ©èœã劚ããããšãªãZendDebugãæ§æã§ããŸãã
ä»åŸãSSHãã³ãã«ãäœæããå¿ èŠãããããšã«æ³šæããŠãã ããã ãã®å Žåã«SSHãã³ãã«ãå¿ èŠãªçç±ã«ã€ããŠå°ã説æããŸãã
ããã©ã«ãã§ã¯ãZend Studioã¯ãããã°ãµãŒããŒã«HTTPãªã¯ãšã¹ããéä¿¡ããŠãªã¢ãŒããããã°ã»ãã·ã§ã³ãéå§ããŸãã ãã®èŠæ±ã«ã¯ãZendDebugïŒãµãŒããŒã«ã€ã³ã¹ããŒã«ãããŠããïŒãZend Studioãžã®æ°ããæ¥ç¶ãéå§ããŠãããã°æ å ±ãäžç¶ãããšãã«äœ¿çšãããªã¿ãŒã³ã¢ãã¬ã¹ãã©ã¡ãŒã¿ãŒïŒIPã¢ãã¬ã¹ãšããŒãçªå·ïŒãå«ãŸããŠããŸãã ãšããã§ãZend Studioã«ä»å±ã®ã³ã³ããŒãã³ããã€ã³ã¹ããŒã«ããããšã«ãããIDEãšãã©ãŠã¶ã®äž¡æ¹ãããããã°ã»ãã·ã§ã³ãåæåã§ããŸããããã¯éåžžã«äŸ¿å©ã§ãã
ããšãã°ãã³ãŒããWEBãµãŒããŒãããã³IDEãããŒã«ã«ã³ã³ãã¥ãŒã¿ãŒã«é 眮ãããŠããå Žåã¯ãå®æçãªãããã°ã»ãã·ã§ã³ãè¡ãããŸãã
ãã ããå€ãã®å ŽåãWebãµãŒããŒã¯IDEãã¡ã€ã¢ãŠã©ãŒã«ãã«ãŒã¿ãŒããããã·ãªã©ãšå ±æãããŸãã ããã¯ãSSHãã³ãã«ã圹ç«ã€å Žæã§ãã
ãã³ãã«ã®å Žåããããã°ã»ãã·ã§ã³ã確ç«ããããã»ã¹ã¯ã2ã€ã®äž»èŠãªã¹ãããã§æ§æãããŸãã
-SSHãã³ãã«ã®äœæã
-SSHãã³ãã«ãä»ããŠãã©ãã£ãã¯ãéä¿¡ããããã®Zend Debuggerèšå®ã
SSHãã³ãã«ãä»ãããããã°ã»ãã·ã§ã³ã®å³ã¯ã次ã®åœ¢åŒãåããŸãã
SSHãã³ãã«ãä»ããéåžžã®ãããã°ã»ãã·ã§ã³
Zend Studioã¯ãããã©ã«ãã§ããŒã10137ãéããŸãã以äžã®äŸã§äœ¿çšããŸãã å¿ èŠã«å¿ããŠãå¥ã®ããŒããå²ãåœãŠãããšãã§ããŸãã
LinuxãŸãã¯Mac OS Xã§SSHãã³ãã«ãäœæããã«ã¯ãã³ãã³ãã©ã€ã³ããå®è¡ã§ããŸãã
ssh <Zend StudioããŒã>ïŒ127.0.0.1ïŒ<ãããã°ãµãŒããŒãéãããã®ããŒã> @äŸïŒ
user@workstation:~> ssh -R 10137:127.0.0.1:10137 user@debugserver user@debugserver's password: <enter user's password on the debug server> Welcome to the Debug Server! user@debugserver:~$
Microsoft Windowsã§SSHãã³ãã«ãäœæããã«ã¯ã PuTTYã䜿çšã§ããŸãã æå¹ãªSSHæ¥ç¶ãäœæããåŸãããã«ãã³ãã«ãæ§æããå¿ èŠããããŸãã
IDEãããããŒã10137ãšããŒã«ã«IPã¢ãã¬ã¹127.0.0.1ããªãã¹ã³ããŠããããšã確èªããŸã
ãã©ãã£ãã¯èª¿æŽã®å®è·µã¯ãä»ã®ç®çã«åœ¹ç«ã€å ŽåããããŸãã ããšãã°ããªã¢ãŒãããŒã¿ããŒã¹ã§127.0.0.1ãªã©ãšã®æ¥ç¶ã®ã¿ãèš±å¯ãããŠããå ŽåãããŒã«ã«ãŠãŒãã£ãªãã£ã䜿çšããŠDBMS SQLãã³ããå®è¡ããŸãã
äžèšã®ãªã¹ãããã誰ã§ãæ¯æ¥äŸ¿å©ãªããŒã«ãèŠã€ããããšãã§ãããšæããŸãã ãããŠããã®éçºã¯ããã«å€ãã®åã³ããããããçåã«çããŸãã ãªãç§ãã¡ã¯åãã€ããŠããã®ã§ããããïŒã
ãããã°ãšãšã©ãŒã®ãªãã¹ã¯ãªãããã楜ãã¿ãã ããããæž èŽããããšãããããŸããã
udpã php-consoleãè¿œå ãããããšãArik