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

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

Related

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.

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 hits a breakpoint only when using external IP address

Using MacOS Sierra, PhpStorm and Xdebug, web application configured on port 80 (not running from PhpStorm).
When browsing to localhost:80/index.php, PhpStorm won't stop on breakpoint, when accessing the external IP 192.168.1.2/index.php, PhpStorm hits the breakpoint.
I would like to use localhost for debugging instead of the external IP.
Is there a way to make PhpStorm to work with localhost?
P.S. Visual Studio Code works in both scenarios (therefore I believe Xdebug and PhpStorm are working good).
[xdebug]
zend_extension = /usr/local/Cellar/php56/5.6.29_5/lib/php/extensions/debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.idekey=vagrant
xdebug.remote_host=0.0.0.0
Tried to set xdebug.remote_host to 127.0.0.1 and localhost, same behavior.
When debugging localhost:80, xdebug log show:
Log opened at 2017-01-03 14:06:36
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to ::1:9000.
W: Creating socket for '::1:9000', poll success, but error: Operation now in progress (19).
E: Could not connect to client. :-(
Log closed at 2017-01-03 14:06:36
When using VS Code, there is no error and xdebug shows instead I: Connected to client. :-)
Setting xdebug.remote_connect_back to 0 (the default value) solved the issue.
Xdebug documentation:
If enabled, the xdebug.remote_host setting is ignored and Xdebug will
try to connect to the client that made the HTTP request. It checks the
$_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables
to find out which IP address to use.
When Xdebug tried to connect to localhost, it used TCPv6, which PhpStorm doesn't support.
Changing remote_connect_backto 0 caused Xdebug to use the remote_host value, using TCPv4, which PhpStorm supports.

PHPstorm 10.0.3 Error 502 Bad Gateway (Due to JavaVM?)

I have installed PHPstorm 10.0.3 Trial, and PHP in my Apache folder on Windows machine, however when I use PHP interpreter I'm getting error 502 Bad Gateway around 50-90% of time.
When this is only HTML page, it works 100%of time.
Edit:
What I do is 'run' my template.php(or any other)file which then appears in browser with url: http://localhost:63342/htdocs/template.php
I have tested:
PHP 7.0.2, PHP 5.3(ISS), first one thread safe, second one thread safe disabled, same results. In Webstorm my path is pointing to PHP-CGI.exe which was problem in different topics.
Only hint about what is going on I was able to find out by clicking: PHPstorm/Help/Show Log in Explorer. So anytime I get Error 502 something along these lines comes up:
2016-01-14 09:57:21,510 [1084784] ERROR - ins.io.ChannelExceptionHandler - PhpStorm 10.0.3 Build #PS-143.1770
2016-01-14 09:57:21,510 [1084784] ERROR - ins.io.ChannelExceptionHandler - JDK: 1.8.0_51
2016-01-14 09:57:21,510 [1084784] ERROR - ins.io.ChannelExceptionHandler - VM: Java HotSpot(TM) Server VM
2016-01-14 09:57:21,510 [1084784] ERROR - ins.io.ChannelExceptionHandler - Vendor: Oracle Corporation
2016-01-14 09:57:21,510 [1084784] ERROR - ins.io.ChannelExceptionHandler - OS: Windows 7
2016-01-14 09:57:21,511 [1084785] INFO - ins.io.ChannelExceptionHandler - Channel will be closed due to error
2016-01-14 09:57:24,273 [1087547] ERROR - ins.io.ChannelExceptionHandler - minimumReadableBytes: -2815 (expected: >= 0)
java.lang.IllegalArgumentException: minimumReadableBytes: -2815 (expected: >= 0)
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1143)
at io.netty.buffer.AbstractByteBuf.skipBytes(AbstractByteBuf.java:731)
at org.jetbrains.io.Decoder.getBufferIfSufficient(Decoder.java:131)
at org.jetbrains.io.fastCgi.FastCgiDecoder.messageReceived(FastCgiDecoder.kt:56)
at org.jetbrains.io.Decoder.channelRead(Decoder.java:38)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelReadNow(ChannelHandlerInvokerUtil.java:83)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRead(DefaultChannelHandlerInvoker.java:163)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:155)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:950)
at io.netty.channel.oio.AbstractOioByteChannel.doRead(AbstractOioByteChannel.java:166)
at io.netty.channel.oio.AbstractOioChannel$1.run(AbstractOioChannel.java:38)
at io.netty.channel.ThreadPerChannelEventLoop.run(ThreadPerChannelEventLoop.java:52)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:55)
minimumReadableBytes is changing from record to record.
You are using PhpStorm's own built-in web server, which has some issues right now (especially with POST requests, e.g. WEB-17317).
The solution is to use your own proper web server (Apache/IIS/nginx/whatever).
Define Deployment entry. In place type should be fine, as long as your Apache/IIS can serve files from that location; otherwise either configure web server to be able to do that .. or use another type of deployment (e.g. Local or Mounted Folders for IDE to copy files to another location for you)
Configure it (provide desired URL etc)
Mark it as Default for this project
Now IDE will use that base URL when you will use Open in Browser or Run/Debug actions (NOTE: it will not affect any existing Run/Debug Configurations -- only future ones; you will have to update your current Run/Debug Configurations manually).
This is what worked for me.
I opened XAMPP control panel v3.2.2, I went into Apache->Config->httpd.conf
and changed the below code
Listen 12.34.56.78:80
Listen 80
to
Listen 12.34.56.78:8080
Listen 8080
Also,
ServerName localhost:80
to
ServerName localhost:8080
saved the file httpd.conf and then started the apache below action from the main screen of XAMPP Control Panel v3.2.2 and it started the apache.
After that I opened the browser and MANUALLY typed the address
for example:
If previous address was: http://
localhost:63342/htdocs/template.php (no space inbetween)
the new one would be:http://
localhost:8080/template.php (no space inbetween)
It should run just fine. Refresh the page and you shouldn't get 502 Bad Gateway error.
Remember: If you run your application later it may go back to previous location, All you need to do is, use the new location on address bar which would be (in this case)
http://
localhost:8080/template.php. (no space inbetween)
In your case:
http://
localhost:8080/yourfilename.php (no space inbetween)

Trouble setting up XDebug with MAMP Pro 1.9.2 & MacGDBp v1.3.1

I installed the XDebug package at MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20060613
I put the following into my php.ini file:
zend_extension="/Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-0060613/xdebug.so"
xdebug.remote_enable = On
xdebug.remote_autostart = 1
xdebug.remote_host = localhost
xdebug.remote_port = 9999
I disabled the zend optimizer.
I set the proper port # in MacGDBp.
I do get a proper stack trace from the command line.
What I'd like to do, though, is load a page in Firefox and debug with MacGDBp.
Shouldn't MacGDBp be reading and parsing whatever's coming though the specified port?
Can anyone tell me what I'm missing?
Thanks!
Well, you are a bit unspecific about your concrete setup but there seem to be few things odd with your settings.
I am not using mac and I don't know MacGDBp ... but MacGDBp suggests that it uses the old GDP-protocol. Though XDebug 2 uses by default the new DBG protocol.
You should make that explicit by setting 'xdebug.remote_handler' to your preferred protocol. In my case as I use the new protocol i feed it 'dpgp.
Here you find some information: http://www.xdebug.org/docs/remote
Also it could be that your firewall is blocking the port.
Maybe that'll do it, otherwise tell us more about the symptoms.
Best
Raffael
I was having the same problem.
What I did was:
install the xdebug-toggler plugin for Safari
load the page I was testing
enable the plugin
reload the page
And suddenly it worked.