PhpStorm not listening to breakpoints - phpstorm

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.

Related

Xdebug 3 with Laravel Valet and PHP 8.1 is not working

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

JetBrains Gateway : debug PHP with dbgpProxy failed

I spent hours trying to figure out how, but I can't manage to debug with JetBrains Client... The more I get when I load a page in a browser is
And then it stuck there. Page in browser is loading forever.
Launching dbgpProxy + JetBrains client register IDE
php -v output:
PHP 7.4.28 (cli) (built: Feb 17 2022 16:17:19) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans
Xdebug configuration :
xdebug.idekey=PHPSTORM
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.mode=debug
xdebug.log="/var/log/xdebug.log"
dbgpProxy launch command:
dbgpProxy -i 127.0.0.1:9001 -s 127.0.0.1:9003
JetBrains client configuration
PHP > Debug on host > Xdebug : debug port 9099
PHP > Debug > DBGp Proxy on host : IDE key : PHPStorm, Host 127.0.0.1, Port 9001
Browser extension : Xdebug helper v 1.0.6
NOTE : It worked like a charm with PhpStorm, but with JetBrains Client I miss something which leads the IDE closing the connection.

PhpStorm local debugging stopped working - Do you see problem in setup?

I used to have PhpStorm working brilliantly on my computer. No browser extensions. I could put breakpoints anywhere, go to some URL in browser, hit enter and then I would automatically be taken to breakpoint in given file. Files in project would open up automatically as I stepped through code.
Now, it is a total mess.
First here is my Xdebug info in the xdebug.ini (I don't specify anything Xdebug related in the php.ini):
zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
[xdebug]
xdebug.remote_enable=on
xdebug.default_enable=on
xdebug.remote_port=9000
xdebug.remote_host=localhost
If I run php -v I get
PHP 7.0.15 (cli) (built: Feb 13 2017 10:30:54) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.15, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
iMac:xdebug-2.7.2 $
phpinfo() shows corresponding values set based on my .ini.
In PhpStorm I have PHP CLI set to 7.0, it is showing Xdebug 2.7.2.
Curious about that "Can't load xdebug" message, but php -v doesn't show same message. At first I had zend_extension defined in both php.ini and the xdebug .ini and would see that message when doing php -v but after removing from php.ini the message went away from php -v.
I have no idea if I need to do anything under Debug settings in Build, Deployment, but here is what is there by default:
Also, I have my project set to sync with a remote server but for debugging I don't want to use path mappings. That is how I had it before and PhpStorm messages about debug session ending and no path mappings found was never a problem.
Here is my Run->Config
In the past, I didn't worry about a start URL. No matter what URL I entered in browser it triggered debugging.
And here is what I have tried regarding path mappings:
I did that to see if it would fix things, but no.
My gut feeling says it is either a problem with Xdebug settings, my run->config, or the fact that I am using a virtual host and somewhere there is a localhost entry causing a problem.
So I am at a loss. If I select Listen for incoming... and go to URL, the focus does not go to PhpStorm with current breakpoint. I see in browser that things stopped and I go to PhpStorm and see that debug was triggered. But the second I hit step over or step into the debugging just ends.
Anything glaringly wrong with what I am doing?
Edit: Here is what I see in the xdebug log:
[89603] W: Creating socket for 'dev.courses.com:9000', poll success, but error: Operation now in progress (19).
[89603] E: Could not connect to client. :-(
[89603] Log closed at 2019-10-21 10:42:37
[89603]
[89603] Log opened at 2019-10-21 10:42:37
[89603] I: Connecting to configured address/port: dev.courses.com:9000.
[89603] W: Creating socket for 'dev.courses.com:9000', poll success, but error: Operation now in progress (19).
[89603] E: Could not connect to client. :-(
[89603] Log closed at 2019-10-21 10:42:37
Not sure the specifics of the error... Maybe this hints at something? The question I have is where in the config do I specify localhost vs my virtual host alias? Maybe that is what is messing things up?
You can find out what Xdebug is trying to do by using the xdebug.remote_log=/tmp/xdebug.log setting. This log will indicate which connection attempts are being made, and why they succeed or not.
Ok, so this turned out to be an xdebug issue, though not obvious at first.
Originally I didn't think to check the PHPStorm log. But the PHPStorm log showed
Argument for #NotNull parameter 'remoteFileUrl' of com/jetbrains/php/debug/xdebug/debugger/XdebugDriver.onBreak must not be null
Searching above error took me to
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001498520-xdebug-works-only-with-first-line
Turns out my version of PHPStorm is known to not work with xdebug 2.7 so I downgraded to 2.6.1 and all is well :-)
thanks,
Brian

Xdebug ignores breakpoints (browser and CLI)

I've been trying to setup Xdebug on PHP 7.2 with nginx (or cli) with no avail so far. The breakpoints are simply ignored. Tried activating them with PhpStorm and manually using xdebug_break().
All of the methods are at least triggering Xdebug, as error logs say (you can see the code in question in the picture below), but nothing happens:
Log opened at 2018-04-21 07:50:31
I: Connecting to configured address/port: 127.0.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///Users/riseandcry/Projects/php/jobApplication/index.php" language="PHP" xdebug:language_version="7.2.2" protocol_version="1.0" appid="9859" idekey="PHPSTORM"><engine version="2.6.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="break" reason="ok"><xdebug:message filename="file:///Users/riseandcry/Projects/php/jobApplication/index.php" lineno="4"></xdebug:message></response>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2018-04-21 07:50:31
my config is this:
zend_extension=/usr/local/Cellar/php72/7.2.2_13/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_connect_back=0
xdebug.idekey="PHPSTORM"
xdebug.remote_log=/Users/riseandcry/Projects/php/xdebug/xdebug.log
xdebug.extended_info=1
xdebug.force_display_errors=1
I don't have any other extensions loaded in PHP, and PhpStorm validation shows that everything is correct:
Also, I already reinstalled everything (PHP, nginx, Xdebug), with various methods and it still does not work. My guess is that it's either Xdebug or config at fault, but no idea what.
Would really appreciate some help. I also read pretty much all of the related questions on SO and other forums and since I'm here, you can guess the outcome...
You are on Mac and you are using nginx... This means that most likely you do have php-fpm installed and running. Problem is that php-fpm also uses TCP 9000 port by default ... so right now Xdebug is connecting there instead of PhpStorm (the xdebug log gives a good hint here, if you have seen such response before).
Unfortunately PhpStorm is unable (for whatever reason) to detect that Xdebug port is already used by another app on Mac (but does it fine on Windows/Linux).
You can verify that manually with this sort of command (look for the entry that uses Xdebug port and see the process name):
sudo lsof -nP -iTCP -sTCP:LISTEN
The solution is to change Xdebug port to be 9001 (or any other meaningful number) in both php.ini and PhpStorm settings.
P.S. You will need to restart all debug sessions / disable and enable "phone handle" icon if you are using it. Alternatively just restart the IDE.

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.