I am trying to set a zero-configuration debugging for PhpStorm/Docker/Xdebug.
Xdebug is installed properly (I can see it loaded on phpinfo()):
My PhpStorm setup for debugging is standard, listening on port 9000. Here is the xdebug config I'm using:
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = docker.for.mac.localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 0
xdebug.remote_log = /var/log/xdebug.log
xdebug.idekey = "PHPSTORM"
Off topic: I am also wondering if using xdebug.idekey is the same as providing IDE key through Chrome extension?
When I click on PhpStorm to start listening for connections, and set in the configuration to break on first line, I am getting the following:
Looking at Xdebug logs, it is clear that container connected to client (which is also clear from the fact that I am getting an error when trying to debug).
At this point, I have no manual servers or remote debug configurations set up.
If I define a server and remote debug configuration, and set environment key:
environment:
- PHP_IDE_CONFIG="serverName=docker-server"
And then if I click to debug:
Debugging then works, and no errors appear.
But this is then not a zero-configuration debugging...
What am I doing wrong?
Related
How can I get Xdebug v3.1.1 to display output "beautified" with PHP 8.1?
Is it necessary to turn on some specific Xdebug configuration option in php.ini?
This is how I need the output on screen to look like:
And this is how it currently looks like:
This is my current Xdebug configuration in php.ini for PHP 8.1:
[XDebug]
xdebug.client_host=127.0.0.1
xdebug.client_port=9000
xdebug.mode=debug
xdebug.profiler_append = 0
xdebug.start_with_request=trigger
xdebug.remote_handler = dbgp
xdebug.start_with_request=yes
xdebug.log_level = 0
xdebug.force_display_errors=1
xdebug.force_error_reporting=1
xdebug.show_error_trace=1
xdebug.show_exception_trace=1
xdebug.cli_color = 1
xdebug.trace_format=1
xdebug.show_local_vars=1
You need to also list develop in the debug mode value:
xdebug.mode=debug,develop
https://xdebug.org/docs/all_settings#mode
https://xdebug.org/docs/develop#stack_trace
P.S. Rather unrelated... but better stick to the new Xdebug port (9003) and not old one 9000 -- it was changed for a reason (as it was often conflicting with php-fpm that also uses the same TCP 9000 port by default).
Sure, if it works then do not change .. but it's better to use safer option (may save a lot of troubleshooting time on a new machine/different setup in a future).
ALSO: xdebug.remote_handler = dbgp -- this is Xdebug v2, does nothing in Xdebug 3. And dbgp is the ONLY possible value anyway...
I’ve configured the virtual machine, installed apache2, php, MySQL and xdebug. The website works and I’ve configured VS but nothing happens when I debug the project in VS.
Note I have to use a VM because there is some trickery that is being done with open VPN.
I am no expert with PHP as I come from the ASP.NET world and I have never used Xdebug before.
I've been asked to add some additional information but the /etc/php/7.2/apache2/php.ini file is too large to add into this post. If you want some more information please ask for a section and I will post it.
In the mods-available folder is an xdebug.ini file that contains:
zend_extension=xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change
I've also set up an inbound rule in Azure for the server to a allow port 9000.
When running VS I have set up the Server URL and specified Xdebug Port 9000.
DBGp proxy is not set.
Thank you
Tim
I finally managed to get something to work.
I updated the xdebug.ini like this:
zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 86.180.220.70
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change
xdebug.idekey = "php-vs"
And, crucially, opened the firewall on my machine for port 9000.
Now I can't seem to set any break points in php that actually hit.
I'm assuming this has something to do with path mapping - plenty of stuff on google for Code but little if nothing for Visual Studio...
I have to say the documentation for doing things like this is SHOCKINGLY bad. Most examples are for a Windows php.ini file, not for Linux. If your a seasoned php programmer your probably used to it but for a newbie like me its an absolute minefield.
i'm using PHPStorm and trying to run Xdebug according this video https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/20?autoplay=true.
First part works perfectly (https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/19?autoplay=true), but i'm stuck at second one.
Port 9000 was not working, so i changed it to 10000.
I configured PHP Web Application configuration
and after I press debug button, web is blank
and still loading and PHPStorm is waiting for incoming connection.
I have checked "can accept external connection" at PHP - Debug - Xdebug and xdebug in php.ini configured like this:
[XDebug]
zend_extension="/usr/local/Cellar/php56-xdebug/2.3.3/xdebug.so"
xdebug.remote_enable = 1
xdebug.cli_color = 1
xdebug.show_local_vars = 1
xdebug.remote_port = 10000
xdebug.remote_host= localhost
xdebug.remote_autostart = 1
xdebug.remote_log="/usr/local/tmp/xdebug.log"
xdebug.idekey = "PHPSTORM"
xdebug.ide_key = "PHPSTORM"
xdebug.profiler_enable = 1
xdebug.profiler_output_dir="/usr/local/tmp/xdebug-profiler"
xdebug.profiler_enable_trigger = 1
I tried to validate web server with this result:
I was googling and trying solve this for 6 hours, try to help me please, i`m kind of dummy in this.
Using OS X El Capitan.
I can debug single script, but not a whole website.
When i run this directly online-chef.dev:10000, it says ERR_CONNECTION_REFUSED.
"online-chef.dev" is at local virtual host.
What I am doing wrong?
Thank you so much!
You are tried to debug web page through xdebug. For debug javascript you need install browser extention. This is manual for javascript debugging.
For javascript debug get current extention port and enter in this place:
For XDebug i don't want always click debug button, so i simple enable listen connections. This is manual for XDebug from JetBrains.
Here is my xdebug config that working with listen connections.
xdebug.idekey = "PHPSTORM"
xdebug.remote_port = 9001
xdebug.remote_mode = "req"
xdebug.remote_host = 10.0.2.2
xdebug.remote_handler = "dbgp"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.extended_info = 1
So, when i need debug javascript i click debug button. When i need debug php i just put breakpoint.
First set up debugging instruments often is hard, but it's pays off.
Debugging using Eclipse and XDebug has worked fine on my workstation for a long time and suddenly it stopped. It freezes at 57% saying: "Launching: waiting for XDebug session".
I checked similar questions: here, here, here, here, here, here and here.
I have a following configuration:
Host: Ubuntu 14.10, Eclipse Luna
Server: CentOS 6.5 with PHP 5.6.6 and Apache 2.2.15 running as VM on VitualBox in network bridge mode
XDebug settings in Eclipse
XDebug server configuration (/etc/php.d/15-xdebug.ini):
; Enable xdebug extension module
zend_extension=xdebug.so
; see http://xdebug.org/docs/all_settings
xdebug.remote_enable = On
xdebug.remote_mode = req
;xdebug.remote_host = 192.168.100.4
xdebug.remote_connect_back = On
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_autostart = Off
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.profiler_enable = Off
xdebug.profiler_output_dir = /media/sf_proofhq/web2/log/profiler
xdebug.profiler_output_name = %s%R.cachegrind
xdebug.max_nesting_level = 1000
I have tried the following:
disable remote_connect_back and enable remote_host
upgrade PHP (from 5.5.4 to 5.6.6)
change port from 9000 to 9001 or 9900
restart host, VM/server and Eclipse
check XDebug logs
switch VM network settings to NAT & Host only
Nothing has helped. :-(
I have found a workaround: create a new Virtual Host and new Eclipse Workspace.
UPDATE:
If Eclipse keeps breaking at first line, then do this.
I have a development environment in my computer, I use nginx and PHPStorm with Xdebug for my debugging, I need to debug in my environment but other people also connects to my machine for testing purpose, it is possible that when I active my debug this only affect me and not for they?
Update:
My xdebug.ini looks like this:
zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.idekey = PHPSTORM
xdebug.remote_log = /tmp/xdebug.log
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.remote_handler = dbgp
xdebug.remote_port = 9001
xdebug.remote_autostart = On
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = /tmp
xdebug.remote_host = localhost
The key here is the setting: xdebug.remote_host. The default value is localhost, which guarantees that Xdebug only contact a debug client which is listening on your localhost and configured port
More detail: Xdebug Settings Document
& Remote Debugging Document