Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XDebug profiling in PHP - can't get output

I've got a strange issue. I've setup XDebug to profile a PHP application we're working on. I believe everything is setup correctly but I get no output when I run it. My configuration looks like this:

zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so
[XDebug]
xdebug.profiler_append = 1
xdebug.profiler_enable = 0 (I've tried this both on and off)
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "/debug/xdebug/profiler_output_dir"
xdebug.profiler_output_name = "cachegrind.out.%p"

All the phpinfo() settings match up like they should. The permissions on the output directory are set to 777 right now just so I can test it. I've tried using a directory under public_html as well but no luck. The URL I'm using to launch the profiler is:

http://example.com/my_page.php?XDEBUG_PROFILE
-or-
http://example.com/my_page.php?XDEBUG_PROFILE=1

Neither works. Any help would be GREATLY appreciated!! This app has a 5-6 second page load time and I haven't been able to trace it through code.

like image 777
John Swaringen Avatar asked Aug 10 '10 15:08

John Swaringen


People also ask

How do I trigger xdebug Profiler?

You can also selectively enable the profiler by setting xdebug. start_with_request#trigger to trigger . You can then enable the profiler by using an environment value, a GET/POST parameter, or COOKIE variable of the name XDEBUG_TRIGGER .

What is a PHP Profiler?

PHP Code Performance Profiling A profiler is a tool that measures how some code consumes resources at run-time. It enables to find performance bottlenecks and understand the code's behavior. Blackfire Profiler for PHP enables to profile applications during development, test, staging, and production environments.

How do I know what version of xdebug I have?

To detect whether xdebug is v3 or not by mashing up the @daniel and @bishop's answer. php -r "exit(version_compare('3.0',phpversion('xdebug'),'>=')? 1:0);"; echo $? Useful for shell scripts in Dockerfiles and/or CIs.


5 Answers

There is also problem with /tmp folders on some distributions, i couldnt get output on centos 7 and then i found this

So, i have set

xdebug.profiler_output_dir=/home/jirka/profile

chmod 777 /home/jirka/profile and its ok now.

like image 179
Aiphee Avatar answered Nov 03 '22 20:11

Aiphee


Comment out xdebug.profiler_output_dir and xdebug.profiler_output_name and see whether you can find the output under /tmp/.

like image 33
Hamid Nazari Avatar answered Nov 03 '22 22:11

Hamid Nazari


Another possible cause of this issue is the permissions on the folder of profiler_output_dir.

Adding write permissions to the group and owner resolved the issue for me:

sudo chmod go+w /home/dimitris/cachegrind/
like image 35
Dimitris Baltas Avatar answered Nov 03 '22 20:11

Dimitris Baltas


Also, beware of access restrictions, such as access rights, groups, owner and SElinux...

like image 36
greg Avatar answered Nov 03 '22 22:11

greg


The full path was required, not just the path:

xdebug.profiler_append=1
xdebug.profiler_output_dir ="/home/username/debug/xdebug/profiler_output_dir"
xdebug.profiler_output_name = "cachegrind.out.%s.%H"
like image 33
k0pernikus Avatar answered Nov 03 '22 22:11

k0pernikus