Xdebug
תוכן עניינים |
using vim
old debuger
- https://mutelight.org/minimal-guide-to-debugging-php-with-xdebug-and-vim
- http://xdebug.org/docs/remote
- http://tech.blog.box.com/2007/06/how-to-debug-php-with-vim-and-xdebug-on-linux/
install http://www.vim.org/scripts/script.php?script_id=1658
To run a script from web app:
http://mysite.com/?XDEBUG_SESSION_START=1
To run a script from CLI:
Terminal 1:
1. export XDEBUG_CONFIG="idekey=session_name" # נראה שהערך עוזר אם רצים כמה דיבגרים במקביל אבל אם רק אחד העיקר שמוגדר והשימוש הוא בפורט 9000 2.2. php myscript.php
Terminal 2:
1. vim 2.1. Press F5 (you have 10 sec to do step 2.2)
- F2 to step into
- F3 to step over
- F12 to inspect the property under your cursor.
- ,e will allow you to evaluate arbitrary code. To fully inspect a property like array , type print_r($var, true) from eval mode
local vim remote server php
http://ccpalettes.wordpress.com/2013/06/03/remote-debugging-php-with-vim-and-xdebug/
work
ln -s /home/user/.gvfs/SFTP\ for\ user\ on\ 10.0.0.4/home/sites/blabla/cr1 cr1
dont work in .vimrc
let g:vdebug_options["path_maps"] = { \ "/home/sites/blabla/cr1": "/home/user/.gvfs/SFTP\ for\ user\ on\ 10.0.0.4/home/sites/blabla/cr1 cr1" \}
Unknown Exception, Connection closed, stop debugging
('vim.error', None, <traceback object at 0xb6c3c89c>)
vim xdebug break point dont work
vdebug newer debuger
https://github.com/joonty/vdebug http://ccpalettes.wordpress.com/2013/06/03/remote-debugging-php-with-vim-and-xdebug/
need Vim compiled with Python 2.6+ support not on rhel5. To chech in vim do
python import sys; print(sys.version)
runing is like the old version
<F5>: start/run (to next breakpoint/end of script)
<F2>: step over
<F3>: step into
<F4>: step out
<F6>: stop debugging (kills script)
<F7>: detach script from debugger
<F9>: run to cursor
<F10>: toggle line breakpoint
<F11>: show context variables (e.g. after "eval")
<F12>: evaluate variable under cursor
:Breakpoint <type> <args>: set a breakpoint of any type (see :help VdebugBreakpoints)
:VdebugEval : evaluate some code and display the result
<Leader>e: evaluate the expression under visual highlight and display the result
</div>
vdebug set start poing
install
vim install vdebug http://thorpesystems.com/blog/debugging-php-in-vim/ WIKIR63-300616
using vdebug in cli php vdebug cli php xdebug cli vim vdebug
Vdebug show options
--Admin 13:57, 30 ביוני 2016 (IDT) on CENTOS7 fail to use from CLI F5 don't work! maybe vdebug & xdebug parameters
- look like port 9000 was busy by php-fpm , moving to 9002 solve the issue
:VdebugOpt port 9002
- and allso in xdebug.ini...
vim /etc/php.d/xdebug.ini
Profiling
http://www.xdebug.org/docs/profiler
https://www.youtube.com/watch?v=v0pQNe5JIoI
in order not to run it allways we will set in etc/php.d/xdebug.ini
xdebug.profiler_enable_trigger = 1
index.php?XDEBUG_PROFILE=1 in this way it will be active per one POST/GET only! you need to add XDEBUG_PROFILE=1 to the URL
in cli
to de/activete xdebug after install
vim /etc/php5/cli/conf.d/20-xdebug.ini
comment /un comment
;zend_extension=xdebug.so
to profile in php.ini or /etc/php5/cli/conf.d/20-xdebug.ini
xdebug.profiler_enable=1 xdebug.profiler_output_dir=/var/tmp
analizing Profile output
webgring https://code.google.com/p/webgrind/
kcachegrind http://kcachegrind.sourceforge.net
אלטרנטיבות
xhprof https://github.com/phacility/xhprof
APD
http://pecl.php.net/package/apd
Stack Traces
http://xdebug.org/docs/stack_trace
Function Traces
http://xdebug.org/docs/execution_trace
firefox extantion
http://manual.pohape.ru/xdebug/
פונקציות שימושיות לשיבוץ בקוד
http://xdebug.org/docs/all_functions
xdebug_break();
LAMP XAMPP
http://theindexer.wordpress.com/2008/06/11/installing-xdebug-on-xampp-for-linux/
/opt/lampp/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
more on LAMP XAMPP
ubuntu
http://www.anil2u.info/2013/03/install-xdebug-in-ubuntu/
install xdebug ubuntu 14.04
http://wylbur.us/2014-06-17-add-xdebug-to-ubuntu-1404
/usr/lib/php5/20121212/xdebug.so
more /etc/php5/cli/conf.d/20-xdebug.ini
zend_extension=xdebug.so
RHEL
yum search xdebug
php-pecl-xdebug.i386 : PECL package for debugging PHP scripts
using yum
yum install php-pecl-xdebug
it add /etc/php.d/xdebug.ini file and the line:
zend_extension=/usr/lib/php/modules/xdebug.so
using pecl
http://ulaptech.blogspot.co.il/2010/11/how-to-install-and-configure-xdebug.html
pecl install xdebug
fail
other to try http://programming-review.com/installing-xdebug-on-centos/
files: ... /etc/php.d/xdebug.ini /usr/bin/debugclient /usr/lib/php/modules/xdebug.so
troubleshooting
Xdebug session timeout
Find php.ini and add the following line to the xdebug section.
xdebug.remote_cookie_expire_time = 3600
not help
php locate code bottleneck
http://a32.me/2013/05/discover-php-bottlenecks-with-xdebug-or-why-my-site-is-so-slow/