Xdebug 3 with Laravel Valet and PHP 8.1 is not working - phpstorm

I'm running PHP 8.1 with Xdebug 3 installed. And I have installed Laravel Valet.
I've tried so many things to make Xdebug work. I want to run it on port 9003
but unfortunately couldn't.
My php.ini Xdebug settings are (as you can see the commented settings that I was trying many things).
[xdebug]
zend_extension=xdebug.so
xdebug.remote_autostart=1
xdebug.default_enable=1
xdebug.remote_port=9003
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM
Below from here are all commented settings:
;xdebug.mode=debug
;xdebug.start_with_request=yes
;xdebug.client_host=localhost
;xdebug.client_port=9003
;zend_extension="xdebug.so"
;xdebug.start_upon_error=1xdebug.client_host=127.0.0.1
;xdebug.client_port=9003
;xdebug.force_display_errors=1
;xdebug.force_error_reporting=1
;xdebug.idekey=PHPSTORM
;xdebug.log=/tmp/xdebug.log
;xdebug.log_level=7
;xdebug.mode=debug
;xdebug.output_dir=/tmp
;xdebug.remote_autostart=1
;xdebug.remote_enable = 1
;zend_extension=xdebug.so
;[xdebug]
;xdebug.remote_enable = 1
;zend_extension=xdebug.so
;xdebug.start_with_request=yes
;xdebug.remote_autostart=1
;xdebug.mode=debug
;xdebug.discover_client_host = true
;zend_extension="xdebug.so"
;xdebug.remote_enable=1
;xdebug.remote_port=9001
;xdebug.remote_handler="dbgp"
;xdebug.remote_host="localhost"
;xdebug.idekey=
;xdebug.remote_enable=on
;xdebug.default_enable=on
;xdebug.remote_autostart=off
;xdebug.remote_port=9001
;xdebug.remote_host=localhost
;xdebug.profiler_enable_trigger=1
;xdebug.profiler_output_name=xdebug-profile-cachegrind.out-%H-%R
;xdebug.var_display_max_children = 128
;xdebug.var_display_max_data = 512
;xdebug.var_display_max_depth = 3
;xdebug.remote_enable = 1
;xdebug.idekey = PHPSTORM
;xdebug.show_error_trace = 1
;xdebug.file_link_format = phpstorm://open?%f:%l
These are my PhpStorm settings:
Any help please ?

The following config should be enough to get you going with php 8.1 and xdebug 3
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.log=/tmp/xdebug.log
Also share the path to the .ini where you are keeping the xdebug settings. If you have cli and fpm subfolders under the config path for php 8.1, you would have to make sure both fpm and cli can read the xdebug settings

Related

Xdebug Specified URL is not reachable, caused by: 'Request failed with status code 400'

I am trying to setup Xdebug with PhpStorm. When I try and validate my script, I get the following error:
Specified URL is not reachable, caused by: 'Request failed with status code 400'
The error used to display a 404 status code, but I applied the fix on this page: https://www.jetbrains.com/help/phpstorm/validating-the-configuration-of-the-debugging-engine.html#troubleshooting-validation-results
I haven't seen anything online for fixing a 400 status code.
I have the site setup on a local environment using nginx and an upstream using php-fpm.sock.
upstream site_backend {
server unix:/var/run/php/php7.4-fpm.sock;
}
And here is my xdebug.ini:
GNU nano 4.8 /etc/php/7.4/fpm/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
xdebug.idekey = "PHPSTORM"
The site works, only Xdebug isn't working. PhpStorm is not registering anything from Xdebug.
Not sure what else is needed, let me know if you need anything else.
UPDATE:
Xdebug is version 3.0.4.
In the nginx error log, I saw something that might be helpful:
2021/04/19 10:26:08 [error] 736434#736434: *72 access forbidden by rule, client: 127.0.0.1, server: mysite.localhost, request: "GET /_intellij_phpdebug_validator.php HTTP/1.1", host: "mysite.localhost"
UPDATE 2:
I made the changes at https://xdebug.org/docs/upgrade_guide, still isn't working. Here is the update xdebug.ini:
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.session=PHPSTORM
xdebug.start_with_request=yes
Not sure if it's correct configuration. I also double checked to make sure PHPStorm is listening on port 9003, which it is. I also restarted php-fpm as well.
I got the same issue and I was able to resolve this buy just replacing the default URL assigned (http://127.0.0.1) with my virtual host URL in PHPStorm > Run > Web Server Debug Validation > URL to validation script.
OS: Ubuntu 20.04.3 LTS
PHP version: 7.4.3
XDebug version: 2.9.2
/etc/php/7.4/mods-available/xdebug.ini:
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
xdebug.mode=debug
xdebug.start_with_request = yes
I got the same problem and I resolved this buy just
changing the value in the php.ini file of the xdebug.start_upon_error from the default "default" to "yes" due too https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html#configuring-xdebug-docker
I got the same issue by using ddev ( = a docker wrapper).
The absolute path to my project is /var/www/html in ddev.
I had to write /var/www/html as the absolute path to my project in the phpstorm settings at php>servers.

How to open port 9000 on Windows 10 for Xdebug to work correctly?

While testing in PhpStorm, I get the following error in the logs:
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9000 (fallback through xdebug.client_host/xdebug.client_port)
Here is my Xdebug config in php.ini:
[XDebug]
zend_extension = c:\localserver\php8.0.2\ext\php_xdebug-3.0.3-8.0-vs16-x86_64.dll
xdebug.client_host=localhost
xdebug.client_port=9000
xdebug.discover_client_host=1
xdebug.profiler_append=0
xdebug.mode=debug
xdebug.start_upon_error=yes
xdebug.output_dir="c:\localserver\php8.0.2\temp"
xdebug.profiler_output_name="cachegrind.out.%t-%s"
xdebug.remote_handler="dbgp"
xdebug.idekey="netbeans-xdebug"
Windows брандмауэр выключен.
This error disappears when I configure XDebug to port 80
But still, I want to properly configure XDebug, for this I need to open port 9000. Please tell me how to do this?
After reinstalling the project, everything worked by itself, but I still don't know what was the cause of the error. I believe that the reason was that I created the project before I installed PHPUnit globally and configured XDebug. Although of course I could be wrong.

PhpStorm not listening to breakpoints

I have been struggling for hours regarding Xdebug and PhpStorm but I cannot get it to work, I have done the following:
1. Installed Xdebug sudo apt-get install php-xdebug
2. Edited the php.ini file /etc/php/7.0/apache2/php.ini
[Xdebug]
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
xdebug.max_nesting_level = 512
xdebug.file_link_format = phpstorm://open?%f:%l
3. Check the version php --version
PHP 7.0.33-10+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 7 2019 09:50:44) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33-10+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
4. Restart the service sudo service apache2 restart
5. Configure PhpStorm
Go through - Settings >> Languages & Frameworks >> PHP
Set the PHP Interpreter, to do so; click on three dots [...] button
On the new window; click on plus [+] button and select /usr/bin/php from suggestion popup.
Save and close this window and select the interpreter
I set the breakpoint and started listening
I access the url http://localhost/debug/file.php and nothing happens. I honestly don't have much more to say, I will share some files you might see what I have wrong.
What files should I share? This installation is based on https://gist.github.com/thomascys/7bf160bfe354eb74a8bb8b75e19038f4
/etc/php/7.0/apache2/php.ini
[Xdebug]
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
xdebug.max_nesting_level = 512
xdebug.file_link_format = phpstorm://open?%f:%l
Now that you have setup PHP in PHPStorm, check your settings under "Languages and Frameworks", disclose the "PHP" entry and select the "Debug" option. The settings revealed include a link named "Validate debugger configuration on the Web Server." Click on it and attempt to validate. It will give you more details on PHP and XDEBUG. If validation passes then click on "Install browser toolbar or bookmarklets." and follow the directions. This adds bookmarks lets that will have your browser submit page request with the necessary cookies to trigger xdebug.

PhpStorm 10 + PHP 7.0.3 + xDebug 2.4.0RC3 not working

I've followed all the suggestions I've found, but I can't get PhpStorm working with PHP 7 and xDebug. I did have it working with PHP 5.6.
Xdebug is being loaded by PHP. I verified in the phpinfo() output. I've switched PhpStorm to use the PHP 7 version and it also lists the correct debugger as xdebug 2.4.0RC3
My xdebug settings are:
zend_extension = "/usr/local/opt/php70-xdebug/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
xdebug.scream = 0
xdebug.cli_color = 1
xdebug.show_local_vars = 1
xdebug.idekey = PHPSTORM
I have the xdebug chrome extension installed, and it's correctly adding the Cookie:XDEBUG_SESSION=PHPSTORM;. I also enabled the debugging listener in PhpStorm.
Can anyone suggest what else I can do to try get my breakpoints to trigger?
So, in my case, I found that by moving the port from 9000 to 9001 fixed. I guess something else was already using the default port. Problem solved!
In case someone else lands here. For me the solution was that the path to the binary wasn't using "quotes".
[xdebug]
zend_extension = "C:\wamp\bin\php\php7.0.16\ext\php_xdebug-2.5.1-7.0-vc14-x86_64.dll"

phpStorm, xDebug and Chrome debugging

I have reinstalled phpStorm 8 and Wamp 2.5
I set the appropriate php.ini file with the following.
zend_extension = "e:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11.dll"
;
[xdebug]
xdebug.remote_enable = true
xdebug.remote_port="9005"
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "e:/wamp/tmp"
xdebug.show_local_vars=0
In phpStorm under Stettings->PHP->Debug
I then set a breakpoint and start the debug listener in the top right screen of phpStorm.
I have downloaded the JetBrains IDE Support 2.0.8 extension for google chrome and set the port to 9005 as-well.
but phpStorm never stops on a breakpoint and I dont get the incoming convection messages that phpStorm normally gives when debugging?
Any help will be appreciated.