I am trying to convert my recent XAMPP development setup to a LAMP stack based on WSL2.
So far I've been successful. I can access my testpage test.php containing <?php phpinfo(); via https://localhost/test.php (using a self-signed certificate for dev-purposes.)
Sadly, I'm completely stuck at getting Xdebug to work.
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
I have been going through these threads already, but to no avail:
My setup:
My Xdebug settings at /etc/php/8.0/apache2/php.ini:
[xdebug]
xdebug.mode=debug
xdebug.remote_port=9003
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.remote_host=localhost
xdebug.idekey=PHPSTORM
xdebug.discover_client_host=1
;xdebug.client_host=localhost
;xdebug.remote_enable=1
;xdebug.remote_handler=dbgp
I have tried commenting "discover_client" and explicitly setting the client host to localhost. No change.
The output of phpinfo() seems to indicate that these settings are not ignored. See screenshot of the relevant parts.
The relevant settings for the virtual host in /etc/apache2/sites-available/default-ssl.conf are:
<VirtualHost: *:443>
ServerName localhost
DocumentRoot "/mnt/d/projects/testproject/public"
<Directory "/mnt/d/projects/testproject/public/">
Options +Indexes +Includes +FollowSymlinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
(The "all granted" is only temporary while debugging)
I don't know if this is relevant, but I made sure that C:\Windows\System32\drivers\etc\hosts contains
127.0.0.1 localhost
::1 localhost
So when I run
php -dxdebug.mode=debug /mnt/d/projects/testproject/public/test.php
I get
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
Does anyone see the problem? Or can anyone give me a hint on where to look next?
The option xdebug.start_with_request = yes tells Xdebug to try to debug every single request/script. If Xdebug fails to connect to the debug client (it takes values from xdebug.client_host and xdebug.client_port, or autodetected host if xdebug.discover_client_host is enabled) then it notifies you about that.
Normally such a messages will be written to the standard PHP's error log. Looks like you don't have it configured at all in your php.ini (as this is how it comes by default), therefore PHP sends it to your standard output instead.
If you want to prevent it from appearing on you terminal output you have to point the PHP error_log to a valid location.
Example of how I solved it in my case:
1- Edit your ini file:
sudo vi /etc/php/7.4/cli/php.ini
2- And add this line:
error_log = /var/www/log/php_error.log
NOTE: Change the previous routes to any valid directory you want.
3- Try again and the warning should disappear and now goes to the log file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With