I have a full installation of Xdebug on my PHP local install, but when I try to run Xdebug inside of my Sublime Text project, for some reason it does not recognise any of the breakpoints. I have tried many things so far to get this to work.
Xdebug client installed.
Project File
{
"folders":
[
{
"follow_symlinks":true,
"path": "."
}
],
"settings":
{
"xdebug":
{
"url": "http://localhost:9312/simplephp/"
}
}
}
php.ini:
[xdebug]
zend_extension = c:\wamp64\bin\php\php7.3.12\ext\php_xdebug-2.9.8-7.3-vc15-x86_64.dll
xdebug.remote_enable=1
xdebug.force_display_errors=on
xdebug.force_error_reporting=1
xdebug.remote_host=localhost
xdebug.remote_port=9312
xdebug.remote_autostart=on
xdebug.remote_log="/c/wamp64/www/xdebug/xdebug.log"
Chrome Xdebug extension enabled.
Tried changing the port, looking for instances that are blocking the port etc, but found none.
Also nothing is currently being written to the log (which is an empty txt file).
Any suggestions would be brilliant.
Related
I hope somebody here can help me with my issue:
I recently gotten into my first PHP project and need to set up debugging. I'm aware many people had the same problem before me but I struggle to find a solution.
I need to set up PhpStorm with Xdebug and with all settings made its still not working and when I start my debug session i get stuck at this with no further information:
This is my project setup:
Docker Webapp with Xdebug: 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp
PhpStorm PHP Debug Settings:
Xdebug settings from phpinfo():
Listening to debug connections in PhpStorm is on, starting a debug session create a session via GET: https://localhost/?XDEBUG_SESSION_START=16957 but all my breakpoints are ignored.
Trying to get more information I ran netstat:
Can anyone tell me what I am missing here?
Thank you very much in advance!
Don't use run/debug configurations for web debugging, it's counter-productive. You can initiate debugging connections from the browser directly using zero-configuration debugging.
Disable xdebug.remote_connect_back, it brings more harm than profit, especially with Docker.
xdebug.remote_host is not supposed to be localhost when you are using Docker, this way, the container is trying to send the debug data to itself instead of the host machine. It seems that you are using macOS and Docker for Mac, the correct hostname would be host.docker.internal in such a case.
If after you initiate a debugging session from the browser PhpStorm still cannot catch a connection, we'll need to take a look at the Xdebug log as #LazyOne suggested.
A blog post showing Docker in PhpStorm basics: https://blog.jetbrains.com/phpstorm/2018/08/quickstart-with-docker-in-phpstorm/
i used this setting and it worked :)
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.default_enable=1
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0
xdebug.profiler_output_dir="/var/www/html"
xdebug.var_display_max_depth=20
xdebug.remote_host=host.docker.internal
xdebug.remote_enable=1
xdebug.remote_connect_back=0
with launch.json in vscode
"name": "Listen 9000",
"type": "php",
"request": "launch",
"log": true,
"externalConsole": false,
"pathMappings": {
"/var/www/html": "/Users/folder/project/src"
},
"port": 9000,
With docker-compose.yml:
Trying to set up XDebug on my local WordPress project using Atom, but running into issues. I can set breakpoints in my code but when I load a page it seems to skip right over the breakpoint.
My setup:
php.ini:
[Xdebug]
zend_extension = /opt/php/5.6.20/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=On
xdebug.remote_port="4022"
xdebug.profiler_enable=0
xdebug.remote_host=192.168.95.100
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
xdebug.idekey=xdebug-atom
config.cson:
"*":
editor: {}
"exception-reporting":
userId: "my-user-id-number"
"php-debug":
PathMaps: [
"/remote/path;/local/path"
"/app/public;/Users/my.user/Documents/Work Stuff/Company/Project Name/app/public"
]
ServerAddress: "192.168.95.100"
ServerPort: 4022
currentPanelMode: "bottom"
result of ping mysite.dev
64 bytes from 192.168.95.100: icmp_seq=3 ttl=64 time=0.476 ms
Local by Flywheel setup:
Atom screenshot w/ breakpoint:
When I load the page, the breakpoint doesn't seem to work (the content generated by get_header() is still loaded) and nothing changes in my debug section in Atom. I've already confirmed I'm loading up the right page/template file in my browser.
Something misconfigured, or am I missing a step somewhere?
I've installed Xdebug on my Vagrant server and the XdebugClient plugin for Sublime Text 3. When I start debugging, my page loads in the browser but nothing shows up in the context, watch or stack tabs. The xdebug.log file is also empty. The following are my settings:
php.ini
[CUSTOM]
error_reporting=1
display_errors=true
track_errors=1
[xdebug ]
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_connect_back=1
xdebug.default_enable=1
xdebug.remote_autostart=0
xdebug.idekey=sublime.xdebug
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=10.0.2.15
xdebug.remote_port=9001
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/tmp/profiler"
xdebug.remote_mode=req
xdebug.ini
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=10.0.2.15
xdebug.remote_port=9001
xdebug.remote_log="/var/log/xdebug/xdebug.log"
.sublime_project
"settings": {
"xdebug": {
"url": "http://mysite.dev/",
"path_mapping": {"/vagrant/www/mysite/dist" : "/Users/iii/Documents/Dev/vagrant/www/mysite/dist"},
"super_globals": true,
"close_on_stop": true,
}
}
Xdebug.sublime-settings
{
"close_on_stop": true,
"pretty_output": true,
"launch_browser": true,
"debug": true,
"ide_key": "sublime.xdebug",
"port": 9001,
}
Can someone please tell me what is wrong here?
I was facing a similar problem with Vagrant/Sublime/Xdebug. I found that the latest version of Xdebug (2.6.0) doesn't work well with Sublime. Evidently, there's an XML formatting issue.
I found two things that both solved the problem:
Revert to Xdebug 2.5.5, or
set "super_globals": false, in your config.
(https://github.com/martomo/SublimeTextXdebug/issues/172)
ETA 24 Oct 2018:
In my case, the solutions above were not necessarily a fix, but just helped to avoid the real issue in some cases. The real fix appears to require a change to the Sublime Package: https://github.com/martomo/SublimeTextXdebug/issues/172#issuecomment-410478057
I ended up forking the SublimeTextXdebug (assuming this is the package you're using), patching it, and then replacing the package with the patched version. (There's a pull request in the main repository, but I don't think it's been pulled yet.)
Just in case someone else has the same problem. I was using Sublime 2 with Xdebug without any issues. I upgraded to Sublime 3 and was not able to get Xdebug to break. I went through various posts and tried various recommendations without success, until, I added the setting xdebug.remote_log="/var/log/xdebug/xdebug.log". No idea why, but once this was added, it started to work.
i am trying to debug my php code in netbeans. the code runs perfectly but i am unable to debug it(doesn't stop at breakpoint) and the code runs normally.
i have tried every possible workaround in order to get my xdebug working and has been stuck from past few days.. anyone out there who can help me sort out this issue.
xdebug configuration in .ini file:
zend_extension = /usr/lib/php5/20090626/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=mgiplocalhost
xdebug.remote_port=9000
here mgiplocalhost is my virtual host.
i have tried with other possibilities as well like localhost and ip address but the waiting for connection still exists.
In netbeans->tools->options->debugging when i set my port as 9000 and debug it asks me to change the port since port 9000 is already in use. i have changing the port but the problem persist.
please i need help to sort it out asap. please help me out.
A bit late but thought this should have an answer! To get Xdebug working, the minimal configuration I found I needed in the php.ini file was the line to load the extension:
zend_extension=php_xdebug.dll (pointing to the downloaded dll from the Xdebug site)
And the following Xdebug settings also placed further down in the php.ini file:
[Xdebug]
xdebug.remote_autostart=On
xdebug.remote_enable=On
xdebug.idekey="netbeans-xdebug"
The Xdebug default port was 9000, and that is also what Netbeans was using (Tools -> Options... -> PHP -> Debugging.) If 9000 is in use, you could also set that in Netbeans to be 9001 and in the php.ini file add the line xdebug.remote_port=9001 with your other xdebug settings.
Then try it out after restarting the server.
I have used XDebug semi-sucessfully with PhpStorm and Mamp, but now I want to try using NetBeans for a project. But I can't get NetBeans to connect to XDebug. It just waits until I stop the debugger and then I get a message that NetBeans never got a connection to XDebug, and it asks me to check the settings in php.ini.
Now, as I said it has worked ok with PhpStorm, so I don't think there should be anything wrong with the settings in php.ini, but anyway, here they are:
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
One thing that I found strange was that everyone talks about php.ini being located in /Applications/Mamp/conf, but in that folder there is no php.ini in my setup at least. In /Applications/Mamp/bin/php/php5.3.6/conf on the other hand, there is. So that's the one I have modified. And since it works in PhpStorm I figure it must be right...
But then, why isn't NetBeans able to connect? I'm also using the XDebug plugin for Safari to hook it up in the browser. And the port in NetBeans is set to 9000 as in the php.ini file.
I'm using NetBeans 7.0.1 and php5.3.6.
Anything else I'm missing?
EDIT:
Well, I found the problem for why XDebug wasn't connecting anyway: I am using the add-in for Safari for XDebug, and apparently it had it's own setting for IDE Key, set to 1, while NetBeans had netbeans-xdebug set. Once I changed it to the latter in the add-in I got a connection. The problem is I still get some sort of error. It says: 404 Page not found when I hit the debugger, and the address in the address field is: http://localhost/app_netbeans/index.php?XDEBUG_SESSION_START=netbeans-xdebug
Any idea what is going on here?
BTW, just hitting run inside NetBeans works fine and opens http://localhost/app_netbeans (I have used mod_rewrite to remove the index.php part of urls in CodeIgniter)
EDIT 2:
I found that the index.php part of the address was because in the run configuration in NetBeans there was an "index file" setting that was set by default to index.php. If I removed that to have CodeIgniter "controller" urls without the index.php I got the correct url, but with the xdebu stuff appended after it. But still I get the 404 Page not found when I use the debugger command, but not when I use the run command.
Weirdly enough what I can do is I can hit debug, ignore the fact that it goes to 404 Page not found, and go back to the IDE, hit run and if I have a breakpoint set it will then stop at that breakpoint.
But again, this is not exactly what I would consider normal debugging behaviour... So if anyone knows what is going on I would love to hear it...
Use this config and make sure you update Netbeans to use port 9001.
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_enable=1
xdebug.idekey="netbeans-xdebug"
I found that the port 9000 sometimes conflicts with other applications, and xdebug seems to fail silently if it cant use it.
use the following code..
zend_extension="path to the xdebug.so"
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
[xdebug]
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
and also make sure the port in the netbeans is correct. you can check that in
goto tools menu and select options
in options click on the php and check the port number.
Mine is finally working, so I wanted to post my full php.ini configuration:
[xdebug]
; got this script from https://netbeans.org/kb/docs/php/configure-php-environment-mac-os.html
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_autostart=1
xdebug.idekey="netbeans-xdebug"
zend_extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_log="/Applications/MAMP/logs/xdebug_remote.log"
You may also check if your project is configured to copy to a different directory in the Netbeans project settings. After I changed this setting I had to restart Netbeans and MAMP using the quit command.
Just to note:
No index.php in my start up properties
Stop at first line is turned off in debugging preferences
I do think changing to port 9001 made a difference on my system