Remote XDebug in VS Code - multiple requests in call stack - php

I'm using XDebug with VS Code, and it works flawlessly when I'm debugging something locally. I can step through the breakpoints of each request sequentially in a sane, logical manner.
However, if I try to debug something remote, the requests come in immediately and flood the call stack:
This makes things incredibly difficult to trace. In the middle of looking at a breakpoint, a new request will come in, the window will pop over to that breakpoint, and I'll lose my spot. Why is this happening?
Note: my remote setup is pretty simple:
I'm using a simple SSH tunnel for port 9000 from the server to my local system
The remote files are mounted to my local system using SSHFS, and I opened that location using VS Code
In my launch.json, I have pathMappings configured to "/remote/system/files": "${workspaceFolder}/" so that the debugger knows where to look for the source.

Related

Laravel connection stays open too long

I am developing a PHP laravel application. I noticed that it is too slow and after careful debugging I realized that the processing is not slow, but the problem is that the connection takes too long to be terminated and so in this time it does not accept a new request.
The following figure shows the performance analysis of a request. Regardless of the type of request, it takes 20-30 seconds to close a connection.
The following figure shows the logs of the local run. The first request was accepted and the second only after the first one was closed, which took more than 20 seconds, although the response comes back in a few milliseconds.
Does anyone know how to fix this?
There is not a lot to go on in your question, however one thing we can see from the log messages is that you are using the PHP built-in server (or php artisan serve which uses it). This is well known to be very slow, single-threaded, and can cause PHP applications to stall:
Should I rely on "php artisan serve" for a locally based project?
PHP built-in web server running very slow
Using the PHP built-in server in production
Max concurrent connections for php's built in development server
Presumably this is your local dev environment - the PHP docs warn not to use the built-in server on the public internet:
Warning
This web server is designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.
Using nginx or Apache and PHP on your production server you should see much better performance. For local development you might be better off setting up Docker, or WAMP, or XAMPP, or the servers included with your distro if you're on some flavour of *nix.

Remote X-Debugging PHP stuck while Server-2-Server communication

I am developing a web service using PHP, which will fetch data through a curl-call from a foreign website.
For developing, I use an Apache Webserver with PHP on a raspberry pi in my local network (call it Server A).
For testing purposes, I've also set up a dummy service to avoid to many useless or bad request to the foreign service. This dummy runs on another Raspberry, with the same Setup, call it Server B. On both Servers A and B, I've deployed XDebug. For developent, I use Netbeans.
When I remotely debug PHP-Scrips on Server A everything runs fine, unless I run/debug a scrip in which a curl-call to the Dummy-Service on Server B is made. If that is the case, the execution halts until I exit the debugging mode. If I do so, the scrips finish normal.
I am not sure what makes the scrip halt, so I've no idea how to avoid this.
What can I do to make debugging work in this case?
OK, found a solution. It obviously is a problem if both servers use the same port (9000) for communicating with the PC I am debugging on.
After setting one of the servers to 9001 instead, i can attach the debugger to one server at a time, depending on what port is set in Netbeans to listen on.

How to debug a site move, for a PHP5/MySQL web application

I have been running a PHP site for years on my own servers. I recently purchased a dedicated server package and am trying to move my site to the dedicated server. I recently upgraded to PHP 5, and my current server is running PHP 5.6.16. I moved the files and the database, and put it in a live test domain, but the site is not functioning properly on the new dedicated server. Several key scripts are non-functional. I made sure that the dedicated server is running a version of 5.6. I have configured it to the same settings I have on the old server. I can see that the site is talking to the MySQL database. I turned on error reporting and I see no significant errors suggesting why these important scripts are now non-functional. I made sure the include path is there, and if it wasn't nothing would work. What am I overlooking? What could be different between one server and the other that might impact PHP functionality? I'm basically at my wits end here, so if these seems stupid please forgive me, but I don't know where to look next.
Start with the basics.
Does your web server respond to static page requests?
Is your web server configured to use PHP?
Can your web server execute and/or connect to PHP?
If you have a simple script with <?php phpinfo(); in it, does it work?
Are all the expected modules there in your phpinfo() output?
Do you have rewrite rules that need to be reconfigured? (Check your web server error log. Check your response status codes.)
Assuming PHP is all good, move into your application.
Are you absolutely sure error logging is on? (Again, check phpinfo() output. Try to force an error, maybe a syntax error or something and see if you see the error.)
How do you know your application is connecting to MySQL?
Start with a basic script that just echos some things.
Comment out large swaths of code and see if you can narrow down the problem that way, re-enabling chunks as you go. (You want to bi-sect the problem, cutting in half and in half and in half until you figure out exactly what the issue is.)
Other system-level things to check...
File system permissions? (See also https://serverfault.com/questions/48587/is-there-a-linux-log-for-when-a-user-is-denied-access-to-files-due-to-permission, for Linux.)
Firewalls? (Are you sure you can actually access MySQL over the network?)
Disk? (Are you out of space? Are your partitions set up correct? Is /tmp full?)
Once you figure out the problem, some advice:
Do this sort of thing regularly. Write a provisioning script to build yourself a new machine from one command, and do it regularly. These days with cloud providers (physical hardware or not) there's no reason you can't blow away your application servers on a regular basis, and re-provision them. Consider making this your system upgrade strategy. (Why reboot to get a new kernel when you can just have a whole new server with the new kernel and other patches, that you can cut over to?)
Ensure your development environment closely matches your production environment. (Consider Vagrant for this.)
You're using version control, right? If not, start using version control so that you can hack on your code for things like this and easily roll back when done.

debugging remote website using eclipase + xdebug

I have spent several hours on the maze of eclipse's setting trying to find out how to debug a remote website but still can't get it to work.
This SO is exactly what I was about to ask, after reading it, I still have something that needs to be clarified so that I can do further research.
1)It says I still need a local version of the website to be able to debug it. I don't get it: if I have to have a local version, why is it called remote debug? Is any change I make to local automatically synchronized to the remote server? Seems no because according to the question I need to manually FTP files to the server?
2)What I am trying to achieve is: with the IDE listening, when I refresh the remote webpage, the IDE takes over and displays the PHP file in its editor. Then I can debug and make changes to it, when I click save, the remote file will also be modified, is this possible at all?
1) You need only the project opened in eclipse. No need to host it in your local machine. Local changes will not be automatically propagated to server until you FTP or rsync.
2) You can add break points in your IDE. Refresh webpage. When it hits break point the IDE will be automatically open(IDE should be configured to listen to remote debug connections) and stops at the line having break point.
You can use IDE plugins to automatically upload file to server and propagate the change. I'm using PHPStorm IDE for achieving the same.
Autoupload

javascript not working after server reboot

Earlier today I had an issue with my server and it crashed so I had to reboot. Since I rebooted it I've been seeing some strange behavior in some of my php pages. Particularly, some javascript stuff doesn't seem to be working at all. (There are some other issues, but I feel like they're stemming from the failing javascript.)
I'm still getting used to web programming and using servers, so I have no idea why this javascript wouldn't be working after the reboot. I can post the script here if need be - I don't know if this is just a generic thing or is going to be specific to my script.
For the record it's an Apache server on a Redhat machine.
The javascript is executed in the client browser not in the server, so as long as you did not make any modifications to the javascript files, there should not be anything wrong caused by the server.
Did you try accessing your website using another computer ?
From your comment it appears that the page is loading a javascript library from a network location which it cannot find (http://wks-l0000120674/nephiere/validation.js). Thus it will load if the client machine (not the server) is connected to the network AND the wks-l0000120674 workstation is up and on the network AND the client machine has rights to request files from wks-l0000120674. On the reboot you may have booted wks-l0000120674 off the network (assuming that wks-l0000120674 is part of the same network as the server and the server also provides DHCP services). Make sure you can still get to this location from the client machine.

Categories