quick setup instructions for profiling php scripts on a mac with xdebug + webgrind
Posted: November 25th, 2008 | Author: sofia | Filed under: useful | Tags: mac, performance, webgrind, xampp, xdebug |These instructions are for xampp on a mac.
- Download xdebug.so from activestate (thank you Komodo)
- Copy xdebug.so (choose the correct xdebug according to your php version) to xampp/xamppfiles/lib/php/php5/extensions/no-debug-non-zts-########/xdebug.so .
- Configure php.ini:
At the end of php.ini (it’s in xampp/etc/php.ini) addzend_extension=/Applications/xampp/xamppfiles/lib/php/php5/extensions/no-debug-non-zts-20060613/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_host = localhost
xdebug.show_local_vars=1
xdebug.dump.SERVER=HTTP_HOST, SERVER_NAME
xdebug.dump_globals=On
xdebug.collect_params=4
xdebug.profiler_enable=On
xdebug.profiler_enable_trigger=On
xdebug.profiler_output_name=”%p-%R”The “xdebug.profiler_output_name=”%p-%R”" sets the file name to process pid (default) + “-” + the REQUEST URI (helpful if you’re rewriting urls). The xdebug.dump commands are not for profiling but they improve var_dump & error messages. Check zend’s article series on xdebug for more info.
- Run php info & check xdebug’s there.
If you get ‘could not load.. (null)’ you probably downloaded the wrong version for your mac. Also check the path to xdebug is correct (theno-debug-non-zts-####### part might be different) - Install webgrind: download from here and copy directory to xampp/xamppfiles/htdocs folder
- Visit your script with ?XDEBUG_PROFILE=1 appended to the end of the url. Eg http://localhost/myapp/index.php?XDEBUG_PROFILE=1
- Now navigate to webgrind (eg. http://localhost/webgrind/ ), select the correct file from the dropdown - you can see the files xdebug’s created in yout /tmp directory - and you should see the profiling info.
- Done!
Sources:
- http://debuggable.com/posts/setting-up-xdebug-on-mac-os-x-or-win32-linux:480f4dd6-0240-4a90-8fa1-4e41cbdd56cb
- http://devzone.zend.com/article/2899-Profiling-PHP-Applications-With-xdebug - this is a really good intro to xdebug
Might be interesting:





Leave a Reply