Xdebug with PHPStorm 8 -- opens WRONG file at non-existing breakpoint - debugging

I am having trouble using Xdebug with PHPStorm. I have searched Google, etc.
I have Xdebug setup on a remote host with my local files mirroring the remote host. I am using the Xdebug Chrome extension.
When I run the debugging through PHPStorm, it OPENS a file and shows a blue-highlighted breakpoint that does NOT exist at that file. It will stay there until I hit "resume" multiple times until I get to the file I actually want to debug. VERY annoying because then the session on Chrome timesout, so I can't debug.
I do not see any code that says xdebug_break(); and I never added a breakpoint to that file. In other words, there are no red markings at the left of the line numbers.
What is going on and how do I fix this? Has anyone else come across this problem?
I have tried skipping and ignoring the file ... still does not work! Yes, I have also viewed breakpoints through a separate window and it does not show the breakpoint that apparently exists.

Check the configuration on PHPStorm stop at first line property and disable it
After that go to Run >> Break at first line in PHP scripts
Try turning it ON and OFF few times. Sometimes it is get stuck in between: showing OFF but in reality it is ON.
This is a well known issue Read: https://youtrack.jetbrains.com/issue/WI-17389

I was having the same problem with my PHPStorm/xdebug config. It turned out I had the path mappings wrong when I mapped the root of the local file directory to the Absolute path on the server - Settings->Languages and Frameworks -> PHP -> Servers.
I fixed the mapping and the system is behaving predictably once again.

Related

VSCode Live Server - Changes URL to /undefined

Was using LiveServer no problem for quite some time, suddenly I go and refresh the page and it changes /index.html to /undefined. Nothing I do fixes it, if I erase the /undefined, it displays the proper page for a split second then returns to /undefined.
I have attempted to uninstall & restart VSCode then reinstall, unsure what to do from here.
Turns out you cannot use certain words in your JS code or it will ruin it.

Xdebug Remote Debugger seems to jump to random locations

My problem is, that the debugger always stops at the first breakpoint I set (doesn't matter where I set it in the code) but when I continue the execution it seems to jump to a random location in the code. Doesn't make any difference here if I use "step into, "step over" or "continue". I checked if any key on the keyboard is stuck but I can't find anything here and I also cleaned the browser cache and invalidated the PhpStorm caches. After some random time it works normally again and I can step around like I want.
The other weird part is, that it always jumps to the same random location from every set breakpoint, but every breakpoint got another random location.
I am using PhpStorm (latest Version) and Xdebug 2.7 for Remote Debugging with the following configuration
php.ini:
[Xdebug]
zend_extension="C:\xampp\php\ext\php_xdebug-2.7.0alpha1-7.0-vc14.dll"
xdebug.remote_enable=true
xdebug.remote_port="9000"
xdebug.remote_connect_back=true
xdebug.remote_autostart=1
xdebug.collect_return="0"
xdebug.profiler_enable=0;
xdebug.remote_log="D:\xampp\logs\xdebug.log"
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host = 192.168.1.129
PhpStorm:
I got this problem every 2nd or 3rd day at the moment for a few hours and just can't figure out what is going on.
Is there maybe a shortcut or anything like that, that I activated without knowing it?
So i just had the problem again and it seems that removing the watches (as suggested here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000602950-XDebug-Remote-Debugger-seems-to-jump-to-random-locations) fixes it. I will keep an eye on this and post an update if the error occures again and removing the watches doesn't fix it.

Pyzo will not start after fontcolor change

I am currently using Pyzo and changed its font and background color according to the instructions on their website (http://www.pyzo.org/pyzo_themes.html) by changing the init() in the base.py file. Everything was fine until I wanted to change the settings back to normal. When I try to open any .py file Pyzo gives me the error
"Error loading file: local variable fore1 referenced before assignment".
On closing the error message, the Shell just keeps warming up and nothing happens. On the left side where the editor would have been, there is a small white box with a smaller yellow one inside.
Opening up Pyzo on its own does not give the error, but the same problem with the Shell and editor.
I tried:
changing the settings in base.py manually to their default value
copying the backup file I made before the changes back into the directory
uninstalling Pyzo with IOBit Uninstaller to catch all hidden files and reinstall it (about 10 times already)
I thought reinstalling it would resolve the matter but obviously there must be a different issue here. I really hope someone had the same problem, thanks in advance for any help!

Xdebug doesn't stop on breakpoints even when it logs a break, but says it is connected to client

I've been trying for a couple weeks to get my PHPStorm to connect to a remote host via Xdebug. Most recently I discovered that the client's host blocked port 9000. I finally have that fixed and now the xdebug log shows that it's connecting to the client (me, of course).
However, it doesn't stop on any breakpoints. Breakpoints set in PHPStorm don't even show up in the log. calling xdebug_break(); at least gets logged as a break, but it still doesn't stop.
based on other questions here I've confirmed that xdebug is loaded with zend_extention=/full/path/xdebug.so and not with extension=xdebug.so
I've also tried switching from port 9000 to port 9001, with no change in the results.
The log entry is:
Log opened at 2015-06-09 14:41:10 //and many other dates and times
I: Checking remote connect back address.
I: Remote address found, connecting to MY.IP.HE.RE:9000. //similar message on port 9001 after trying that
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///chroot/home/company/remotehost.com/html/index.php" language="PHP" protocol_version="1.0" appid="2294" idekey="PHPSTORM"><engine version="2.2.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2013 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:///chroot/home/company/remotehost.com/html/app/code/community/Zzyzzx/Stores/controllers/TestController.php" lineno="11"></xdebug:message></response>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2015-06-09 14:41:13
The file it's getting that from has 3 breakpoints set in the IDE and one coded in on line 11.
What might be causing it to fail to follow breakpoints and let me debug?
The path that I used in the server settings was /home/company/remotehost.com/html mapped to my project root, which contains the same files. I understand this to be the absolute path from root, and if i understand it's confirmed by the log showing a break from the code. It is the only file with a path set. Do I need to set the path for EVERY file?
I also tried deleting the server in hopes of triggering the dialog, but it wasn't triggered, I just get exactly the same log entry with the new time/date/IP.
I just discovered that whenever I attempted to reload the page i'm debugging, in my "run" menu there is an option to "resume program" which brings up a list with the file i'm trying to debug. clicking on that opens the debug tool window where the message "waiting for connection from JetBrains IDE Support extension for Chrome..." is displayed. Isn't this for debugging javascript? Is it trying to debug my PHP as Javascript?
Also I tried using a couple of other xdebug clients with similar results. it connects and then gives the same messages. Makes me think it's not PHPStorm.
Everything I've tried was trying to debug the following code:
class Zzyzzx_Stores_TestController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "in the controller 1 <br />";
xdebug_break();
echo "in the controller 2 ";
//3 commented lines of unused code
//
//
phpinfo();
//2 commented lines of unused code
//
}
}
Breaks are set in the ide on each "echo", and of course you can see the coded break.
Debugging this locally worked fine.
One reason the breakpoints won't work is due to the odd case-sensitivity of Mac OSX.
I've found that if a filename doesn't match the case of the class the breakpoints for just that one file won't work, even though the rest of the application debugs fine, and "break at first line" shows the debugger is generally working.
The filesystem on OSX is essentially case insensitive, but strangely the command-line is case-sensitive which can fool you into thinking it's more like other case-sensitive Unixes. This then lulls you into believing there cannot ever be a case-mismatch because it would be totally broken and you'd notice!
However I feel OSX really operates more like Windows - very forgiving in this respect, until you upload your files to Linux server...
I had a class called LegacyJsonMetadataMapper in LegacyJSONMetadataMapper.php. The autoloader works fine, the app works fine, PHPStorm doesn't mention the difference in case - I didn't notice it. But it simply would not fire any breakpoints. An hour of fiddling with mappings and server configs later (which have been working for years!), then I read a PHPStorm bug report which mentioned this aspect on the side. I changed the case, and the breakpoints now work.
Note, this also happens if any folder in the namespace path doesn't match the case of the namespace "slugs" too. I just had this same problem (some breakbpoints working, some not).

PHPStorm / debugger not stopping at certain breakpoints

I've set up XDebug (2.2.1) and PHPStorm-IDE (Mac OS X 10.7.5) with standard LAMP stack for Mac OS (Apache 2.2.22, PHP 5.3.15).
/etc/php.ini
[xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.file_link_format="txmt://open?url=file://%f&line=%1"
xdebug.remote_enable = On
xdebug.remote_autostart = "PHPSTORM"
xdebug.var_display_max_data = 1024
xdebug.dump.GET=*
xdebug.dump.POST=*
xdebug.show_local_vars=On
xdebug.dump.SERVER=*
xdebug.dump_globals=On
xdebug.collect_params=4
I followed these two tutorials and it works in 99% of my project files:
http://blog.jetbrains.com/webide/2011/03/configure-php-debugging-in-phpstorm-2-0/
http://blog.jetbrains.com/webide/2011/02/zero-configuration-debugging-with-xdebug-and-phpstorm-2-0/
I use Zend Frameworks MVC architecture. I am able to stop at breakpoints in most of my controller classes, but in some other controllers PHPStorm ignores all of my breakpoints.
Do you have any suggestions? How can I debug the debugger? What kind of configuration error could cause that?
Thanks for your help.
This almost has to be the result of mismapped paths in phpstorm. You can configure paths in Settings->PHP->Servers. I ran into a similar problem and all I had to do was to set the correct absolute path on the server (where xdebug is running) in the mapping for the root of my code in phpstorm. e.g. c:\my\code\lives\here\on\my\dev\box => /myserver/my/code/lives/here/on/my/actual/server.
Here is a more complete solution, and some tips on debugging XDebug in general:
Add a remote log file to your xdebug settings: xdebug.remote_log = /path/to/logs/xdebug.log
Restart apache
Tail the log (I'm assuming you can do this in OSX)
tail -f /path/to/logs/xdebug.log
--You might see something obviously wrong by keeping track of the log contents the next time you try to debug a page. If so, just do whatever you need to do. If not, let's still assume it's a mismapping of paths and continue to try to fix that:--
Set a breakpoint where you know PHPStorm/XDebug will actually stop and make it stop there. In a lot of places on the web people report index.php being the easiest place to make PHPStorm actually stop at a breakpoint for the first time.
In a file that you can't get PHPStorm/XDebug to stop in, set and unset a breakpoint while PHPStorm is stopped at the breakpoint in the index.php file. You should see lines in your xdebug log file that look like this:
<- breakpoint_set -i 19 -t line -f
file:///myserver/my/code/lives/here/on/my/actual/server/file.php -n
159
->
See if the file actually does live where XDebug is looking for it e.g.
tail /myserver/my/code/lives/here/on/my/actual/server/file.php
If the file doesn't actually live there, adjust the path mappings in your PHPStorm settings until PHPStorm is telling XDebug to look at files that actually exist. e.g. if XDebug had said file=/mysrver/my/code/lives/here/on/my/actual/server/file.php, then in step 6 you would have noticed the file didn't exist on the server, and then you might realize "oh oops I spelled myserver wrong in the path mapping", and fixing the spelling in PHPStorm would then probably fix the issue.
This is a bit of an old thread but hopefully this will help someone eventually :)
OK, I had the same problem and dug around the PHPStorm bug tracking and also their dev forums.
It turns out that you need to make sure that the path to the file in which breakpoints don't work are exactly as they are (lower/upper case wise) on your MAC. I just migrated a project from Windows with mixed upper/lower case folders and file names on the drive and different cases in the require_once directives.
Once I made sure the path in the require_once matched the case on the disk, then my breakpoints started to work again!
See here http://devnet.jetbrains.com/message/5488439
This usually means the controllers aren't called.
If it does work for certain controllers (within the same project) it just means: the code wont get called.
So get a few steps up to see the correct controllers is called. (e.g. from the dispatch and then dive into until the controller gets loaded).
And is it possible that you work remotely (e.g. from local to another server). Than it can take a little time before it the code is placed on the server. Just wait a few seconds and than try again. Since how can it break on a point that it doesn't know?
Hope this helps to get you started to debugging it.
This happend to me too several times. Usually the debugger's configuration is the reason. You have to set the path mappings of the debug server correctly under "Run > Edit configurations".
Possible reasons for NOT stopping at breakpoints:
the IDE refuses the debug connection requests coming from the remote server. The telephone icon has to be green (Run -> Start Listening For PHP Debug Connections) in order to avoid this.
all the breakpoints are muted. Turn breakpoint muting off.
the Suspend checkbox of a particular breakpoint is not checked. Check them one-by-one in Run -> View Breakpoints. The tick means "Suspend Execution", not "Suspend the breakpoint", as one may think. (The current version of PHPStorm I use seems to be buggy, if I check the Suspend checkbox then it doesn't take effect yet. I have to click another breakpoint and then click back in order to "submit" checking the checkbox.)
If you want to debug a script invoked from a browser then the browser should set a cookie called XDEBUG_SESSION with the value of the idekey. You can initiate it by extending the URL this way: http://192.168.99.100/?XDEBUG_SESSION_START=PHPStorm. Be aware of the expiration of the cookie which is only one hour. There are useful browser add-ons for easing handling the debugger cookie. See https://xdebug.org/docs/remote#starting for more.
the individual breakpoint is not Enabled. Check them one-by-one in Run -> View Breakpoints.
the individual breakpoint has some condition that doesn't get met. Check the Condition setting of the breakpoint in Run -> View Breakpoints.
there is some mapping issue between the remote server and the IDE. When you set a breakpoint in the IDE then it sends the remote server that the execution should stop at the Nth line of the F file. There is a mapping between your local files and the files on the remote server. The mapping is defined in the IDE at the following places:
on the Path mapping field of the Preferences -> Languages & Frameworks -> PHP page
on the Preferences -> Languages & Frameworks -> PHP -> Servers page
If these mappings are incorrect, for example, the local F1.php is mapped to the remote F2.php by accident, then you may have problems. If you set a breakpoint at the line #N in your local file F1.php the server will stop the execution only if the execution reaches the line #N of file F2.php (rather than that of F1.php). If this is the problem then you still can debug your code if you turn on the Run -> Break at first line in PHP scripts flag. Be aware of the different case sensitivity in directory and file names of your development operating system versus that of the remote server!
The IDE is not receiving debug connection requests from the remote server due to some network setting issues. Check the Preferences -> Languages & Frameworks -> PHP -> Debug page whether the IDE is listening on port 9000 for XDebug, check whether it Can accept external connections, and so on.
The XDEBUG-related settings of the remote server are incorrect. I use the following settings in my php.ini
.
xdebug.default_enable = 1
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.idekey = "PHPStorm"
xdebug.remote_autostart = 1
xdebug.remote_host=192.168.1.26
You should set remote_host to the IP address of your development computer, or you can omit the whole line if your server is on localhost.
Plus, I set the following environment variables:
export PHP_IDE_CONFIG="serverName=halmaiXdebug"
export XDEBUG_CONFIG="idekey=PHPStorm"
where the value of the serverName is the Name of the server I defined on the Preferences -> Languages & Frameworks -> PHP -> Servers page in the IDE.
UPDATE: Too old PhpStorm version also can cause breakpoint issues. With PHP 7.4 on the server and PhpStorm 2018.2 locally, the execution stopped at the first instruction but not at any further ones. After upgrading to a newer PhpStorm version (2020.1), it works as expected.

Resources