Using XDebug with SublimeText on a WAMP server - php

I have been hacking away at this for hours, and at one point it was actually working on a test page, but I don't know what happened since then because its stopped working. I've been getting this error a lot:
Error: b'Failed loading c:\wamp\bin\php\php5.6.19\ext\php_xdebug-2.4.1-5.6-vc11.dll\n'
Its strange because it definitely is loading the file, when I add this to my php.ini file:
zend_extension = "c:\\wamp\\bin\\php\\php5.6.19\\zend_ext\\php_xdebug-2.4.1-5.6-vc11.dll"
it tells that it is indeed enabled. In the php.ini file I spotted this: In a tutorial I read, the xdebug.ini file appeared in one of those fields: Heres the full settings in my php.ini file:
then check phpinfo() and I now see a section for xdebug:
Also when I run
if (xdebug_is_enabled()) { echo 'its enabled'; }
[xdebug]zend_extension = "c:\\wamp\\bin\\php\\php5.6.19\\zend_ext\\php_xdebug-2.4.1-5.6-vc11.dll"
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_log= "C:\\wamp\\tmp\\xdebug.log"
xdebug.profiler_enable=0
xdebug.profiler_output_dir = "C:\\wamp\\tmp"
xdebug.collect_params = 4
xdebug.collect_return = on
xdebug.collect_vars = on
xdebug.show_local_vars = 3
I'll be honest, I have no idea what half of those parameters do. Heres the settings for my sublime project:
"settings":
{
"xdebug":
{
"url": "localhost/xdebug_test"
},
"sublime-view-in-browser": {
"baseUrl": "http://localhost/xdebug_test",
"basePath": "C:\\wamp\\www\\xdebug_test"
}
}
and inside XDebug.sublime.settings I added the URL in there:
"url": "http://localhost/xdebug_test"
Heres the index file in the xdebug_test folder:
but when I start the debugger and launch the browser, it instantly echoes test, and nothing appears in the xdebug console:
It worked on that exact file yesterday, I don't know what could have changed since then.
Is there a way to diagnose whats wrong with it? I don't think so because this isn't just happening in sublime text, heres what happens when I ran a PHP script in the terminal:
EDIT: I just spotted in phpinfo() that the IDE Key is set to PHPSTORM. Thats strange because in the xdebug settings file, its set as this:
"ide_key": "sublime.xdebug",
Could that be the issue? Is there anything I can do here to further diagnose the problem?

Did you try changing the xdebug url in project settings?
"xdebug":
{
"url": "http://localhost/xdebug_test"
}

What if you use this version of dll - https://xdebug.org/files/php_xdebug-2.4.1-5.6-vc11-nts.dll ? Postfix "nts" means "Non-thread-safe".
And of course you can use XDebug wizard to find out which dll version and which settings do you need - https://xdebug.org/wizard.php

I pasted my info into the wizard and heres what I got
I'll give the non threaded version a try.

I figured out the problem, xdebug was connecting to the wrong port. I found the log file in C:/wamp/tmp/xdebug.log and checked out the latest messages, and there were loads of lines saying the same thing:
Log opened at 2016-10-21 16:09:25
I: Connecting to configured address/port: localhost:9001.
E: Time-out connecting to client. :-(
Log closed at 2016-10-21 16:09:26
I suspected the issue was with the port, I checked the php.ini file and it was set to 9001, then I checked Xdebug.sublime-settings and noticed the port was set to 9000. I set the port in php.ini to 9000 and now xdebug is working.
I still don't know why its giving me those errors about not being able to load the extension. Strange because it definitely is loading them.

Related

In PHPstorm after configuration xdebug, stepover is disabled yet.what should I do? and one addition warning

Please guide me
No one here knows how to solve the problem!?
I use PHPstorm 2017.2.4 for php programming.
I configured phpstorm to debug by xdebug for use stepover and stepintro in debugging by jetbrain guid documents but just debugging is enable yet and other options is disable. screen shot of this:
How can I and What should I check to resolve this problem?
I googled and search in stackoverflow but I couldn't find my answer.
Update:
I couldn't solve that yet.
I explain all steps I have done :
first o all say that I use wamp 2.4 for local host server.(php 5.4.12, apache 2.4.4 , MySQL 5.6.12)
1- install phpstorm for use debugger such as step over an step into debugging.
2- use jetbrain guide documents to install debugger:
first check to find xdebug in wamp directory.
then edit last lines of php.ini file in wamp as following:
[xdebug]
zend_extension = "c:/wamp/bin/php/php5.4.12/zend_ext/php_xdebug-2.2.3-5.4-vc9-x86_64.dll"
xdebug.remote_enable = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
3-Set php interpreter as follow image:
4-Then validate debugger here that don't disply any warning:
5-Enable listening for PHP debugger connection
6- Install chrome toolbar JetBrains IDE Support for web debugging.
7- I wentback to PHPstorm to debugging but just debug option was enabled and others was disabled as first image in this post.
In addition, after debugging the codes, the warning : "PHP Warning: include_once(): Failed opening '.\dref.php' for inclusiondisplay this warning. (include_path='.;C:\php\pear') in C:\wamp\www\srn\mrt\req_v.php on line 260" is displayed, while the same code works well in the WAMP(localhost:80) by Firefox browser.
in all php documents that has code similar to below :
include_once ('.\jd.php');
require_once(".\dref.php");
require_once(".\scur.php");
Then when I changed path for example ".\dref.php" in require_once to "..\dref.php" debugging dont display above warning ,But this timewhen open web by Firefox(localhost:80-wamp) display Warning: require_once(..\dref.php): failed to open stream: No such file or directory in C:\wamp\www\srn\mrt\req_v.php on line 26
Where do I make mistakes and how should I solve these problems?
Please guide me
No one here knows how to solve the problem!?

Configuring Xdebug (PHP) path_mapping and php.ini for Sublime3

I'm trying to configure Xdebug to work with Sublime Text 3 but I can't get anything to show in the Context, Watch or Stack tabs e.g. by setting a breakpoint and clicking Start Debugging (Launch Browser). The browser opens the index.php file with ?XDEBUG_SESSION_START=sublime.xdebug appended to the url but execution of the code does not stop when the breakpoint is reached.
I've also tried adding xdebug_break() to index.php to no effect.
From what I've read, specifying path_mapping in the .sublime-project file seems the most likely solution. The documentation states that:
path_mapping
For remote debugging to resolve the file locations it is required to configure the path mapping with the server path as key and local path as value.
I'm using IIS on Windows 10 so the app's files are stored in C:\inetpub\wwwroot\ and the homepage's url is http://localhost/index.php which I'm assuming are the server path and local path respectively and as such the .sublime-project file looks like this:
{
"folders":
[
{
"path": "."
}
],
"settings": {
"xdebug": {
"url": "http://localhost/index.php",
"path_mapping" : {"C:\\inetpub\\wwwroot\\" : "http://localhost/index.php"}
}
}
}
Is this correct? If it is, is my php.ini file configured correctly?
[ExtensionList]
.
.
.
zend_extension = "C:\Program Files (x86)\PHP\php-5.6.30-nts-Win32-VC11-x86\ext\php_xdebug-2.5.1-5.6-vc11-nts.dll"
[XDEBUG]
xdebug.default_enable=1
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_host=localhost
The path_mapping and php.ini settings were both incorrect.
Based on #LazyOne's comment, removed the incorrect path_mapping in the .sublime-project file so it now looks like this:
{
"folders":
[
{
"path": "."
}
],
"settings": {
"xdebug": {
"url": "http://localhost/index.php"
}
}
}
Then added xdebug.remote_log="C:\Windows\Temp\Xdebug\remote.log" to php.ini and inspecting the log showed:
I: Remote address found, connecting to ::1:9000.
E: Time-out connecting to client. :-(
Searching this error lead to #Axel's answer to this SO question and based on this, changed xdebug.remote_connect_back=1 to xdebug.remote_connect_back=0 in php.ini
Breakpoints then started working and the Context, Watch and Stack tabs started showing the relevant data on reaching them.

xDebug stopping at context_get

I'm trying to debug my PHP script using xdebug and xdebug_break() method. It start to working and my IDE (PHPDesigner) stop at the break normally, but instantly it stop. Reading the debug.remote_logs file I can check that the last line is:
<- context_get -i 429 -c 0
After that I don't receive a return with a XML data about GET data. So I guess that there live the problem, but how can I fix that?
My php.ini xdebug config is:
[xdebug]
xdebug.remote_mode=jit
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_log=C:\Wamp\logs\xdebug.log
xdebug.idekey=xdebug
I tried to use the XDBG too, and it throw an exception and stop to working. The remote_logs file show the same fail. Using php_xdebug-2.2.0-5.4-vc9.dll.
Before I do post it, I checked out the xDebug last version and it is php_xdebug-2.2.2-5.4-vc9.dll (diff: old 2.2.0, new 2.2.2). Updating that solve my problem and now all works fine. Yey!

xdebug not running on mamp

I am trying to run xdebug on mamp and followed many tutorials but when i see it in my phpinfo() i don't find xdebug. As xdebug is already included in the mamp as i read.This is line i added in my php.ini and i also went to that location to see if xdebug.so exist or not.but still its not working. any help? i am using mamp 2.1.2
p.s I modified the php version to mine in php.ini from php5 to php5.4.10
I don't know if it's too late but i'm sure that someone will need the real answer.
To solve yo online have to change php.ini in the correct path...
For php 5.4.10 there are two php.ini and I changed both and it works for me.
They are in:
MAMP/conf/php5.4.10/php.ini
and
MAMP/bin/php/php5.4.10/conf/php.ini
When I changed the second one, I reload MAMP and IT WORKS!! If you want to know if it's working, open MAMP on localhost, click phpinfo and find xdebug.
Also, I have to say that I changed in httpd.conf (MAMP/conf/apache) the port 8888 to 80 (you have to change Listen:8888 to Listen:80 and local_host:8888 to local_host:80. (without _) In that case, yo only have to go to http: / / localhost to see your projects
Thanks #titolancreo!!
I was about to give up for today after a couple hours and just by adding the same line in both php.ini it suddenly worked!
you can also do this in your terminal to know if it works:
php -m
You should be able to see the Xdebug module two times, one in the [PHP Modules] list and another one in the [Zend Modules] list.
You also have to check - (you already did I see) - whether the xdebug.so file exists in the location specified in php.ini.
In my case the original line was:
zend_extension="/Applications/MAMP/bin/php/php7.1.0/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"
I finally changed it to point to the correct location and it worked:
zend_extension="/Applications/MAMP/bin/php/php7.1.0/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
No error messages however in php_error.log. I can't figure out why certain .so files are reported as missing in the log and some others aren't, like this one.
make sure that you are listening to the correct port from php.info
for me was
xdebug.remote_port=9900
then in vcode
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9900
},

webgrind on wamp

I just installed wamp and the latest version comes with webgrind, but i cannot figure out how it works.It says
Select a cachegrind file above
And thats all.
Webgrind is a parser/viewer for a profiling file format called cachegrind. The PHP extension Xdebug can (among other very useful things) generate these. For webgrind to work, Xdebug needs to be installed and enabled.
Make sure Xdebug is installed and working (see the Xdebug docs for info on how to do that)
Have Xdebug generate a profiling report by requesting a local PHP file
Load webgrind in the browser and select a file in the popup-menu at the top
Press update, and hopefully everything should work
The wiki on Google Code has more on configuring webgrind.
1) Download XDebug from their download page.
2) Put all DLL files in your PHP extension directory: C:\wamp\bin\php\php5.x.x\ext
3) Add the following line in your php.ini file located in C:\wamp\bin\php\php5.x.x:
zend_extension = c:\wamp\bin\php\php5.3.0\ext\php_xdebug-2.1.0-5.3-vc6.dll
4) Add also the following section to your php.ini (search for the [xdebug] section first to make sure it does not exist yet):
[xdebug]
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "c:\wamp\www\webgrind\tmp"
xdebug.profiler_output_name = cachegrind.out.%t.%p
5) Restart Wamp and verify that the extension was loaded. To do so, add a file pi.php in C:\wamp\www\ and put the following code in it:
<?php
phpinfo();
?>
6) Check the output by opening your browser at http://localhost/pi.php and search for XDebug.
7) Download Webgrind from their download page and extract in in your www folder.
8) Edit the config.phpfile located in C:\wamp\www\webgrind\ to change the storage directories:
static $storageDir = 'c:\wamp\www\webgrind\tmp';
static $profilerDir = 'c:\wamp\www\webgrind\tmp';
9) In the Webgrind directory where you have extracted the code, add an .htaccess file and put this content in it to avoid webgrind from profiling itself:
php_flag xdebug.profiler_enable 0
10) Rerun the http://localhost/pi.php script to generate some profiling data.
11) Open your browser with http://localhost/webgrind to display the results. Do not forget to click the Update button!
This answer is based on an answer provided by Jacob Moen. You can view the original source here.
It is good to watch if the application becomes SLOW, had problems with
it because of the settings of Cachegrind.
Good luck!
My settings are Wamp 2.4, Apache 2.4, PHP 5.4 and MySQL 5.6
[Portugues pt_BR]
É bom prestar atenção se a aplicação se tornar LENTA, tive problemas com isso por causa das configurações do cachegrind.
Boa sorte!
Minhas configurações são Wamp 2.4, Apache 2.4, PHP 5.4 e MySQL 5.6
Update the PHP.INI with these parameters
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
RESTART ALL SERVICES
this should be work.
You don't have to do much....
I just edited the line to be
xdebug.profiler_enable = 1
Thats all buddy. Totally works!

Categories