This is my xdebug configuration in my php.ini
[xdebug]
zend_extension="C:\wamp64\bin\php\php5.6.35\zend_ext\php_xdebug-2.5.5-5.6-vc11-x86_64.dll"
xdebug.remote_log = C:\wamp64\logs\xdebug.log
xdebug.idekey = PHPSTORM
xdebug.remote_port = 9000
xdebug.remote_handler="dbgp"
xdebug.remote_autostart = on
xdebug.remote_start = on
xdebug.remote_enable = on
xdebug.remote_connect_back = on
it is at the very bottom of the file.
As you can see, I have set the xdebug.idekey to PHPSTORM, but phpinfo() shows that the value is not set, what am I doing wrong?
I also set the idekey through PhpStorm, but why is there no value entry in phpinfo() at the bottom? The top one is filled ?!
EDIT from comments and #Black's answer this is the answer :
WAMP use 3 PHP.ini files :
Apache's file : wamp\bin\apache\apache[version]\bin\php.ini
PHP's file : wamp\bin\php\php[version]\php.ini
Third file : wamp\bin\php\php[version]\phpForApache.ini
First two files are usefull, apache's file is used for HTTP calls, PHP's one for CGI/CLI. The third one is used when your WAMP has 2 PHP's version, WAMP use it for saving the current config and then create a new PHP.ini file for the new version. This happens during the switch of PHP's version.
In the Xdebug's case, indeed it was the apache's file that matter. It's a common issue when the phpinfo don't show any modifications.
If you have the same configuration between those two files, you also can make a symlink from PHP's file to apache one. This will save a lot of headache.
UNLUCKY TRIES
Depends on your request, you may want to configure your server with differents things.
You tried to use Xdebug as remote, then your IDEKEY should be SET as environment variable named : DBGP_IDEKEY
Here's the doc :
xdebug.idekey
Type: string, Default value: complex Controls which IDE Key Xdebug
should pass on to the DBGp debugger handler. The default is based on
environment settings. First the environment setting DBGP_IDEKEY is
consulted, then USER and as last USERNAME. The default is set to the
first environment variable that is found. If none could be found the
setting has as default ''. If this setting is set, it always overrides
the environment variables.
You may be concerned by conditions that I pointed out with italic text
as linked in comment, take a look at the full documentation
I remember that WAMP use Xdebug as an Thread safe extension, you should try to
replace
zend_extension="C:\wamp64\bin\php\php5.6.35\zend_ext\php_xdebug-2.5.5-5.6-vc11-x86_64.dll"
by
zend_extension_ts="C:\wamp64\bin\php\php5.6.35\zend_ext\php_xdebug-2.5.5-5.6-vc11-x86_64.dll"
And check if you have download a correct version of Xdebug (Thread Safe)
Then restart wamp and see if something has changed.
EDIT : You have an issue with your PHP.ini, you're not modifying the right one. I succeeded on mine with this :
; XDEBUG Extension zend_extension = "C:\wamp\bin\php\php7.0.4\zend_ext\php_xdebug-2.4.0-7.0-vc14-x86_64.dll" ;
[xdebug]
xdebug.remote_enable=1
xdebug.idekey = "PHPSTORM"
xdebug.remote_autostart= on
xdebug.remote_connect_back= 1
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_mode=req
xdebug.profiler_enable = 0
xdebug.profiler_output_dir = "c:/wamp/tmp/"
xdebug.collect_params = On
xdebug.show_local_vars = On`
The reason why it was not saved is that on wamp you have to store your config in C:\wamp64\bin\apache\apache_VERSION\bin\php.ini instead of C:\wamp64\bin\php\php_VERSION\php.ini.
I searched my whole wamp/bin/php folder for the occurence of the string xdebug by using Notepad++, thats how I found it out.
Related
I try to configure Xdebug Client for Sublime Text 3 on Windows 10 (with PHP Version 7.3.0 and 2.7.0RC2 Xdebug version).
I read issues for days because the panels context were always blank, but I solved it adding "super_globals": false in Xdebug.sublime-settings.
Now the Xdebug Context show:
The problem is the breakpoint never hits. never show me the Steps options (into, over). Even, don't show the little yellow arrow on left side.
I believe that it's related to path_mapping configure, but this really confuse me.
I dont understand why I need configure path_mapping if I work only on localhost on xampp.
php.ini:
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.7.0RC2-7.3-vc15.dll"
xdebug.remote_enable = 1
xdebug.remote_host = 127.0.0.1
xdebug.report_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.remote_connect_back = 0
xdebug.idekey = sublime.xdebug
xdebug.trace_output_dir = "C:\xampp\tmp"
xdebug.remote_log = "C:\xampp\php\tmp\xdebug.log"
You might need to add xdebug.remote_autostart = 1. Per the XDebug documentation:
xdebug.remote_autostart Type: boolean, Default value: 0
Normally you need to use a specific HTTP GET/POST variable to start remote
debugging (see Remote Debugging). When this setting is set to 1,
Xdebug will always attempt to start a remote debugging session and try
to connect to a client, even if the GET/POST/COOKIE variable was not
present.
See: XDEBUG EXTENSION FOR PHP | DOCUMENTATION
Of course, restart your server after adding.
EDIT: See also Derick's answer on this StackOverflow page about using a log file to troubleshoot, if the above doesn't work.
I have read and tried what I've found yet I cannot get it to work, it just keeps on hanging at "Waiting for connection (netbeans-xdebug)" when starting debugging.
I do have xdebug installed (I am using wamp) and I've actually managed to get breakpoints working with sublime text 2 (yea that's right!) so the problem is not with php/xdebug on my pc per se but some setting I am missing.
my php.ini for xdebug:
; XDEBUG Extension
[xdebug]
;zend_extension ="c:/wamp64/bin/php/php5.6.25/zend_ext/php_xdebug-2.4.1-5.6-vc11-x86_64.dll"
zend_extension ="c:\wamp64\bin\php\php5.6.25\ext\php_xdebug-2.5.4-5.6-vc11-x86_64.dll"
xdebug.remote_enable = 1
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0
xdebug.remote_hander =dbgp
xdebug.remote_mode = req
xdebug.remote_host =127.0.0.1
xdebug.remote_port = 9000
xdebug.idekey=netbeans-xdebug
xdebug.remote_connect_back=1
xdebug.remote_autostart=1
Netbeans debugging options are set as defaults except I unchecked "stop at first line" coz I read somewhere to do so.
If you need more info on something let me know.
I've found the issue for myself (since everything else seems to be in order on my side), netbeans will not debug non root urls for some reason, and of course I dont want to open the root every time so I've made a virtual host for that specific project with a regular url (www.someurl.com) and it seems to be working fine now.
Also I am not sure every single line is needed from my php.ini xdebug settings but I've kept it so, since I am not bothered to check for redundant lines, so if you are not sure about your xdebug settings just copy the whole thing from my Q.
I have installed xdebug and tried to use it with phpstorm. But it doesn't want work correctly.
I tried to put following settings to /etc/php5/apache/php.ini and /etc/php5/mods-avaible/xdebug.ini:
zend_extension="xdebug.so"
; Debugging
xdebug.remote_enable= 1
xdebug.remote_port= 9000
xdebug.idekey = "PHPSTORM"
; Var-Display
xdebug.var_display_max_children = 2048
xdebug.var_display_max_data = 8192
xdebug.var_display_max_depth = 99
xdebug.max_nesting_level = 3000
I thought the `xdebug.ini should be the correct place for this settings.
Then I restarted apache with sudo service apache2 restart and opened a page where I print out phpinfo(). But as you can see on screenshot - it says all the time netbeans-xdebug.
What can I do? I searched my whole system for other php.ini files, but there aren't any other files.
This is what works for me.
zend_extension="/usr/lib/php5/20121212/xdebug.so"
[xdebug]
xdebug.remote_enable = on
xdebug.profiler_enable = off
xdebug.show_local_vars=0
xdebug.max_nesting_level = 500
But run following command first to locate xdebug.so
locate xdebug.so
and change following line accordingly
zend_extension="/usr/lib/php5/20121212/xdebug.so"
Solution to my problem.
I figured out that in my browser, even after restarting my system (obviously) a cookie XDEBUG_SESSION=netbeans-xdebug was causing this problem.
After deleting it and reloading my phpinfo() page, my new idekey is PHPSTORM and now xdebug works with my ide.
I think the problem was that I installed xdebug and tried it with my ide without setting it up - so (default?) value for idekey was this netbeans-xdebug value. And as soon as the cookie is set, it will ignore php settings as long as this cookie is alive.
It usually happens (if the path to xdebug.so is correct) because the remote_enable is set to off.
xdebug.remote_enable=on
might solve the issue.
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 ?
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.
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"
If you are on Linux check that you are not in PrivateTmp, otherwise everything is written in /tmp
check this lin which explain PrivateTmp
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
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 .
I'm using (or trying to anyway) use the bundled XDebug with XAMPP 1.7.2. It comes bundled with Apache 2.2.12, PHP 5.3.0, XDebug 2.0.5 and Zend (not sure on version)
This is a totally fresh install of XAMPP, the only thing I've added to php.ini (at xampp/php/php.ini) is:
zend_extension_ts = "C:\xampp\php\extensions\php_xdebug.dll"
[xdebug]
xdebug.auto_trace = 1
xdebug.collect_includes = 1
xdebug.collect_params = 1
xdebug.collect_return = 1
xdebug.default_enable = 1
xdebug.extended_info = 1
xdebug.show_local_vars = 0
xdebug.show_mem_delta = 1
xdebug.trace_format = 1
xdebug.trace_options = 0
xdebug.trace_output_dir ="C:\xampp\tmp"
xdebug.remote_enable=1
xdebug.remote_mode="req"
xdebug.remote_host=127.0.0.1
xdebug.remote_port=17869
xdebug.idekey=<idekey>
xdebug.remote_handler="gdb"
xdebug.auto_profile = 1
xdebug.auto_profile_mode = 2
xdebug.output_dir = "C:\xampp\tmp"
xdebug.dump.SERVER = REMOTE_ADDR,REQUEST_METHOD
(this is only one of many different configs I've tried)
But try as I might, XDebug just will not connect to anything. I've tried Netbeans and Debugclient.exe (in xampp/php/debugclient.exe). They both just sit and wait forever.
How do I get XDebug to work?
My case was quite annoying. Everything was right except for one unexpected thing. The config line
zend_extension = \xampp\php\ext\php_xdebug-2.2.5-5.5-vc11.dll
generated by the XDebug website is wrong. I had to change to
zend_extension = php_xdebug-2.2.5-5.5-vc11.dll
Hope it may save some time if anyone has the same problem as me in the future
If you havent solved this issue. Just in case and for anyone looking for an answer. Go to localhost (if your using XAMPP that is) and click on the left menu's link phpinfo(). Then click anywhere on the table and press "Ctrl + C'. Then go to http://xdebug.org/find-binary.php and paste all the info that you just copied from the table in the white text-box. Click the link below and youll have the right fil to download plus some instructions. Copy that file that you just downloaded into the location stated in the instructions (ie. C:\xampp\php\ext - in my case im using XAMPP 1.7.7). Go to your php.ini file that should hopefully be in 'C:\xampp\php\php.ini' and look for the kay-word '[XDebug]'. No copy the line 'zend_extension = C:\xampp\php\ext\php_xdebug-2.1.3-5.3-vc9.dll' (in my case) under the ';zend_extension = "C:\xampp\php\ext\php_xdebug.dll"' line. Note: make sure you dont put the ';' at the beginning of the new line that you just pasted. Now go ahead and uncomment all the 'exdebug.FUNCTION_NAME' lines that are at the bottom of each block of text.
Restart you server. Go back to your phpinfo() page, copy the table as you did before and paste it in the xDebug website. This should be enough for you to get it working.
PD: make sure that the file that you download from xDebug is approximately 147kb as there has been some instances where people download small files (ei. 3kb).
Let me know how it goes. :)
Xdebug v2.0 shouldn't work with PHP 5.3.
Xdebug v2.1 provides PHP 5.3 support. Otherwise I would get rid of the xdebug ini config except:
zend_extension_ts = "C:\xampp\php\extensions\php_xdebug.dll"
xdebug.remote_enable = On
xdebug.remote_host = "localhost"
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
use this as your test and once this works then add additional configs. Make sure you comment out other zend stuff.
The joomla web site has a great tutorial on getting XAMPP, XDebug, and Eclipse (Netbeans is configured in the same fashion) working together and they cover all major operating systems.
http://docs.joomla.org/Setting_up_your_workstation_for_Joomla!_development
I have faced such a type of problem where i configured as xdebug said for the xampp 1.7.2. Couldn't work. I just changed the zend_extension_ts to zend_extension. it works for me.