26

I using XAMPP and I have configure it in order to have virtual hosts for each project I create localy.

In my php.ini I have enabled xdebug, and my scripts are working properly. I mean that any time there is a warning, notice, error, are reported by the xdebug.

Now I would like to enable the Xdebug profiler, and I have make the following changes into my php.ini in order to allow the Xdebug profiler to generate the log file:

; xdebug.profiler_enable
; Type: integer, Default value: 0
; Enables Xdebugs profiler which creates files in the profile output directory. Those files can be
; read by KCacheGrind to visualize your data. This setting can not be set in your script with ini_set
; ().
xdebug.profiler_enable = 1

; xdebug.profiler_output_dir
; Type: string, Default value: /tmp
; The directory where the profiler output will be written to, make sure that the user who the PHP
; will be running as has write permissions to that directory. This setting can not be set in your
; script with ini_set().
xdebug.profiler_output_dir ="D:\Web Development Projects\Profile"

I restart my Apache, but still when I run my scripts there is no file generated in folder Profile.

Is there anything else I have to do ?

I have read that in order to enable the Profiler : http://xdebug.org/docs/profiler


After some research, I add that code at the end of the index.php in a WordPress installation I have in my server:

echo xdebug_get_profiler_filename();

After I run my WordPress, at the footer I get that result:

D:/Web Development Projects/Profile/xdebug_profile._::1320916508_018294

but when I go to the folder

D:/Web Development Projects/Profile/

the file is not appeared there ? Any idea ?

Xedecimal
  • 3,153
  • 1
  • 19
  • 22
KodeFor.Me
  • 13,069
  • 27
  • 98
  • 166

5 Answers5

26

First of all, you need to make sure that the user under which your webserver runs at actually has write permissions to the directory that you specified— and it needs to exist. It is also possible that Xdebug doesn't like spaces in paths, Although that should work just fine, I would try setting:

xdebug.profiler_output_dir = "D:/Web Development Projects/Profiler"

As the \ + char might be an escape sequence.

Derick
  • 35,169
  • 5
  • 76
  • 99
25

The problem solved !

The problem generated because of the log file name.

I just changed it to:

xdebug.profiler_output_name = "callgrind.out.%t-%s"

and working properly !

Update

I update my code because of the comment provided by the user The Unknown Dev. Based on what he is written the code should be like that:

xdebug.profiler_output_name = "cachegrind.out.%t-%s"
KodeFor.Me
  • 13,069
  • 27
  • 98
  • 166
  • 3
    Note the name should be `cachegrind` instead of `callgrind` if you are using something like WinCacheGrind that only recognizes one type of file. – The Unknown Dev Nov 01 '16 at 15:31
  • @KodeFor.me Can you write all configuration for php.ini file?. I am trying but no use. – Murad Shukurlu May 18 '21 at 06:39
  • @MuradShukurlu this is four years old project, and unfortunately doesn't exists anymore, and on top of that, I don't even remember what options I had set. Useful resources are here: [xdebug.profiler_output_name](https://xdebug.org/docs/all_settings#profiler_output_name) and [string xdebug.trace_output_name](https://xdebug.org/docs/all_settings#trace_output_name) – KodeFor.Me May 18 '21 at 08:45
  • 1
    @KodeFor.Me Thank you!, I have solv the problem after reviewing changelog. – Murad Shukurlu May 18 '21 at 10:37
1

If you are on Linux check that you are not in PrivateTmp, otherwise everything is written in /tmp check this lin which explain PrivateTmp

gdm
  • 7,647
  • 3
  • 41
  • 71
1

I had a similar problem with Fedora Linux v.32. The setup was correct, however I could not find the profiler dump in /tmp.

This was caused because of the RedHat Linux Security Feature: PrivateTmp, introduced also in Fedora 16 and newer.

This means that processes running with this flag would see a different and unique /tmp from the one users and other daemons sees or can access.

In my case the unique directory was:

/tmp/systemd-private-05139aa229424bc389df850760710371-php-fpm.service-vLI9Th
Aris
  • 4,643
  • 1
  • 41
  • 38
  • Solved my problem. I just listed and examined contents of /tmp dir and found the private ones. – Ales May 11 '22 at 06:53
1

Try adding

xdebug.mode = develop,profile

in php.ini

and also print the info with

echo xdebug_info();

In version 3 I think they changed the options like shown here: https://xdebug.org/docs/profiler

Also the new option is

xdebug.output_dir = "Path..."

So this is my entire configuration with XDebug 3

zend_extension = "D:\Dev\XAMPP\php\ext\php_xdebug-3.1.4-7.3-vc15-x86_64.dll"
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9003

xdebug.mode = develop,profile
xdebug.profiler_output_name = "callgrind.out.%t-%s"
xdebug.output_dir = "D:\Dev\XAMPP\php\tmp"

Notice that xdebug.mode and xdebug.output_dir

And I start the server like this

php -d max_execution_time=30000 -S 127.0.0.1:80 -t .
Daniel Georgiev
  • 1,292
  • 16
  • 14