PhpStorm Debugger never enters code, but page doesn't finish loading while debugger is running - phpstorm

I am using PhpStorm on Ubuntu which I'm running on a Hyper-V machine. I'm trying to configure the PhpStorm debugger with XDebug. I've set a breakpoint in my code, but when I click "Start Listening for PHP Debug Connections" in PhpStorm and refresh my page, the debugger never enters my code. The debugger must be doing something because the page in the browser stays loading, until I click Stop in PhpStorm. If I don't click for the debugger to listen for connections, the page loads correctly.
The Debug window shows the error Remote file path '/var/www/magento2/pub/index.php' is not mapped to any file path in project, but I don't know how to get that to map correctly. In the path mappings windows, under "Include path", it shows a bunch of paths, but the path /var/www/magento2/pub isn't there. I can't find anywhere to add an additional path. Could this be a permissions issue for that folder? What permissions do I need to allow PhpStorm to map that path?
If I uncheck "use path mapping" in Preferences > Language & Framework > PHP > Servers and leave "Break at first line in PHP scripts" checked, then the debugger breaks on the first line of code, but I don't want to break until my breakpoint is hit.
If I uncheck "use path mapping" and don't check "Break at first line in PHP scripts", then I get the error Debug session was finished without being paused. It may be caused by path mappings misconfiguration or not synchronized local and remote projects. To figure out the problem check path mappings configuration for 'mydomain.local' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).
Here's my XDebug configuration
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_mode=req
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"
Update:
Here are the responses to #LazyOne's questions
1) The path to the project root is /var/www/magento2
2)
One thing here which I think may be related to the problem is that under Include Path, the /var/www/magento/pub directory is not shown. That's what PhpStorm is referencing on that first error I described above. It's like PhpStorm found some of my directories with PHP files, but not all of them.
3) Here is the XDebug log
Update 2:
Here is what my project looks like
Here is my Directories window
I'm assuming that the reason that all the vendor/... directories are under Excluded Folders is that they are in .gitignore. Some of the code that I'm setting a breakpoint in is in a subdirectory of one of the vendor directories and some of the code is in a subdirectory of app/code/ (which is under Source Folders)
I added /var/www/magento2/pub to the Include Path under Settings > Languages & Frameworks > PHP. That eliminated the error about /var/www/magento2/pub/index.php. Now it's partially working. If I have PhpStorm break on the first line of PHP scripts, the debugger does start as soon as I refresh my page. However, after I step over the first line of code, I get the error PHP CS Fixer: Can not correctly run the tool with parameters... and then the debugger seems to stop working.
If I don't select Break at first line in PHP Scripts, and I put a breakpoint further into my code, I still get the same "debug session was finished without being paused" error.
I'm not sure what PHP CS Fixer is, nor do I want it to run. Is there a way to disable that?

Related

PhpStorm showing "unvailable" breakpoint whereas execution is suspended

I'm sometimes stuck while attempting to debug my code.
Debug Session is active, code execution is suspended :
But I cannot see what really happens, as the breakpoint show "unavailable" ("no parking" symbol):
Does anybody know about this sign ?
I still haven't found any information about it on JetBrains sites... that's why I'm here :-)
(PhpStorm 2020.3, using docker containers (linux containers) with Docker Desktop/ Windows 10)
[EDIT] :
I just noticed that "break at first line in php script" seem to be functioning though:
But I have these weird breakpoints instead of red "normal" ones, and an highlighted line.
I tried restarting my docker containers, same issue. This produces seemingly randomly and gets solved after a while ... (reboot ?...)
[EDIT] SOLVED
The path mapping (local<->docker) for the root of my project was empty (how did it happen...) in my docker configuration in PhPStorm.
I'm not sure how this problem occured, but I'll be able to solve it next time if it's back.
If you try to disable "break at first line in php scripts" you may get the message :
17:38 Debug session was finished without being paused It may be
caused by path mappings misconfiguration or not synchronized local and
remote projects. To figure out the problem check path mappings
configuration for 'docker-server' server at PHP|Servers or enable
Break at first line in PHP scripts option (from Run menu). Do not
show again
In my case, the path mapping for the root of my project was incomplete "Absolute path on the server" was emtpy. I don't know how it happened but you could check :
In PHP | Servers

Console command for opening files inside already opened project in PhpStorm

I've faced the problem. I use PhpStorm to edit files from FTP server using WinSCP client. In WinSCP client I've set command for using external editor. So, when I try to open php-file from remote FTP server WinSCP downloads this file in temporary file and open it using command provided by me - "C:\Program Files\JetBrains\PhpStorm 2020.1.1\bin\phpstorm64.exe" "!.!"
Earlier, when I used PhpStorm 2019 or 2018, it opened file in already opened window/project. But when I've upgraded to PhpStorm 2020, it started to open file from FTP in separate windows. It's so annoying and some functionality doesn't work in such case (auto suggestions and others).
I know that I can use built-in remote files browser within PhpStorm to view and edit remote files, but I accustomed to use separate FTP client for such purposes.
Does somebody know how to fix this problem? What console command should I use so as to open separate file in already opened window/project?
It's a LightEdit mode: https://blog.jetbrains.com/idea/2020/04/lightedit-mode/
Since 2020.2 you can use the -p (--project) option instead to force opening files in already opened project windows. For example idea -p myfile.txt. IDEA-237118
You can also permanently disable that mode by following these steps:
Invoke Help | Find Action... (or via Search Anywhere: use Double Shift and switch to Actions tab)
Search for Registry... action and select it
Once in the Registry dialog locate light.edit.file.open.enabled entry (just start typing, speed search will narrow it down) and set it to false (uncheck the box).
Not sure if IDE restart is needed (probably not).

Deploying libgdx to html

I tried deploying Libgdx to html using gradle. I copied the content
html/build/dist
and all I see in the browser is the badlogic image with a red background (what you would see if you just created a project) Why is that?
Using the superdev I can open it in the browser, i see where it says drag this button but can't play it. there's nothing
The code server is ready at http://127.0.0.1:9876/
GET /clean/html
Cleaning disk caches.
Cleaned in 29ms.
GET /superdev.html
[WARN] ignored get request: /superdev.html
[WARN] not handled: /superdev.html
> Building 91% > :html:superDev^C%
turning the dev mod on I see Can't find any GWT Modules on this page.
If I build it normally, I see some warnings about depreciated methods, it builds successfully.
Assets aren't being loaded by html
I've few links that may be help you :
How to start
Super Dev mode in GWT
Also check this thread
https://stackoverflow.com/a/24265470/3445320
EDIT
I've tested on Android Studio with MacOS
Steps :
Run ./gradlew html:clean to clean your html module
On Android Studio Terminal I run ./gradlew html:superDev command
I got The code server is ready at http://127.0.0.1:9876/ on terminal
Then I open Google Chrome, View -> Always Show Bookmarks Bar
I typed http://127.0.0.1:9876/ in adress field -> enter
I got a page having Dev Mode On and Dev Mode Off, two buttons
Drag Dev Mode On to bookmarks bar, that is below my Address bar
Done! now I search http://localhost:8080/html/ , I got my game in browser
Press Dev Mode On button that is in bookmarks bar, I got option for compile
Now I need to deploy my html project
I run ./gradlew html:dist in Android Studio Terminal
I got BUILD SUCCESSFUL in Terminal then I find dist folder inside my html module.
dist folder is inside html module -> build -> dist
I copied dist folder and deployed to my server.
EDIT 2
Make sure badlogic.jpg is in your assets folder of android module
Check entry in assets.txt file and find badlogic.jpg inside html module->war->assets folder. If file or entry not exist.
Somehow program not able to write in assets folder
Check what programs have the file/s open
Check permissions and administrative rights
Delete the cache files, run "gradlew html:clean html:superDev" for every new run of superDev.
Check any anti-virus software, they can flag some of GWT's behaviour as suspicious

PhpStorm - xDebug on demand not attaching

I tried out your new feature "xedbug on demand". I stuck to these guides (https://www.jetbrains.com/help/phpstorm/2016.3/configuring-xdebug.html and https://blog.jetbrains.com/phpstorm/2016/06/xdebug-on-demand-for-cli-php-scripts-in-phpstorm-2016-2-eap/).
I see that in the php Server menu when I add the path to the xdebug that PhpStorm recognizes it (the label switches from "not installed" to "XDebugger 2.4.1").
So everything seems to be fine but when I use the debugger via the bug-icon, it never attaches/stops for the breakpoint.
I activated the xdebug-Logfile, but it stays completely empty.
Furthermore I commented everything xdebug-related out in the php.ini.
The xdebug-port is still on 9000 (default).
Any ideas what I can do about it?
Update: I'm using the debugger via phpStorm's "PHP Web Application" and the debug-icon. I'm debugging php files which are executed via an apache vHost.
PS: Checked IntelliJ forum and Stack posts, didn't find anything helpful though...
"Xdebug in demand" option works for CLI debugging only (Run/Debug Configuration of "PHP Script" type; will also work for other CLI-mode configs, e.g. "PHPUnit") be it local or remote.
Quote from the aforementioned introduction blog post:
To use the great new feature, first, you need to disable Xdebug for command line PHP scripts.
That option does not work for web pages served via web browser (e.g. Apache/nginx/IIS) or when just listening for any incoming debug connections (Zero-config approach) where actual debug is initiated outside of IDE.
The reason is very simple: when launching debugger for CLI script, IDE launches your php executable (your configured PHP Interpreter, e.g. php.exe on Windows) with additional parameter (-z: check php --help output or here) that can load such additional extension.
But when you debugging a web page then whole PHP is not controlled by PhpStorm: it's your web server (Apache/nginx/IIS/etc) that communicates with PHP .. and you cannot pass such arguments at this stage.

Enable XDebug in Behat

I am using behat+mink. I wrote some features and am now running tests.
How can I enable xdebug to to stop on breakpoints in phpstorm when running behat tests ?
I have not tried this with Mink yet, but this is configuration that allows me to step through debugging of behat (with behat running on a remote server):
Configure your server with x-debug
Of note, since this is commandline, you need to edit the cli config under /etc/php5/cli/conf.d/20-xdebug.ini.
Set remote_host to the ip of the computer you're using PHPSTORM from
Set autostart = 1
Disable connect_back, you will initiate debugging from the server so there is nothign to connect back to
You can also do this without editing your ini by exporting values as env variables, just remember to do this each time you start a new shell (or add to your .bash_profile file):
export XDEBUG_CONFIG="remote_host=<YOUR IP>"
Configure PHPStorm's Debugger
It seems by default, PHPStorm doesn't understand remote-cli scripts, so we need to add a configuration that tells it to expect a CLI script to trigger xdebug
Open the Run Menu and select "Edit Configurations"
Click the Green "+" to to add a new configuration and select "PHP Remote Debug"
Name the Configuration (E.G. MyServer-Behat)
Under the Servers: menu, select your remote server.
If you haven't configured your remote server yet, then do this by clicking the "..." button on the right
Click the Green "+" to add a server configuration. Give it a name (E.G. MyServer) and fill in it's address under Host
Configure it's Path Mappings. This is important if the path to your source files is different on your PHPStorm computer from your server. You can see in my example that i'm relating my local checkout (~/Work/Symfony/) to my server install (/var/www/). I specifically added mappings for src, bin, web, app, and vendor by clicking in the space to the right under "Absolute path on the server" and typing in the path. I had issues just mapping the root's, so I had to add these paths to get my debugger to work.
Debug!
Once that is setup, select your configuration from the drop down in the debugging tool bar and click the bug icon (you can also use the Run menu) to start the debugger listening. This is similar to the default Telephone Button (circled in yellow), but it tells PHPStorm to use your new configuration.
Now simply run behat like you normally would from your server and your debugger should connect and stop on any breakpoints you've placed.
If you're having doubts about if it's working or not, try toggling the "Break on First Line" in the Run menu, as this should make the debugger break immediately when you run behat (in the bin/behat file)