Xdebug 3: Debugging Remote Code with VS Code

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • In this video I am showing how you can set up VS Code and the PHP Debug Adapter to debug a source code that is only available on the remote machine, without having to have any source code locally.

Комментарии • 28

  • @rpbale
    @rpbale Год назад +2

    This is an important video. Thank you for creating it. But please repost with audio levels corrected.

    • @DerickRethansXdebug
      @DerickRethansXdebug  Год назад

      I can't replace the video with the audio improved unfortunately.

  • @Empstec
    @Empstec 8 месяцев назад +1

    Thanks, after weeks without undertand why I couldn't debug remotly I fix it with that... My problem was "pathMappings" client configuration. No other tutorial and documentation explain it.

  • @natenatters
    @natenatters Год назад +1

    Really appreciate all of the xdebug videos, very well made + edited. Thanks!
    Do you really use remote debugging? Or is this more for people who write code on a remote machine.
    For me personally, the volume on this video was a little low. But with full volume you sounded fine :)

    • @anrdaemon7115
      @anrdaemon7115 Год назад +2

      I always use remote debugging, since projects are located in a remote environment. Be it a VM in the contractor's infrastructure, an LXC container at my own server or a docker container in a local VM, the principle is the same. While VS Code offers a way to leverage SSH access to work directly on the remote host, it requires connection with satisfying speed and reliability, which is not always available.

    • @natenatters
      @natenatters Год назад

      ​@@anrdaemon7115 Yeah that makes sense. I have only worked with one company that had the code on a remote machine (Really remote, i.e. not on my laptop) and the syncing with PHPstorm was always annoying.
      I use xdebug through docker too, which is a breeze to setup now.
      I meant more, debugging production/ staging environments. Sounds like a last resort for me.

    • @anrdaemon7115
      @anrdaemon7115 Год назад

      @@natenatters debugging production environment us really last resort. There's no reason to do so, unless your product management is really absent.
      Debugging stage is also a bad idea, esp. if it is used as internal UAT platform.

  • @ttyp11
    @ttyp11 5 месяцев назад

    Can anyone explain why when pathMappings is used, the ssh:// is remapped to a local physical path e.g. /ssh:/ instead of being interpreted as a remote file?

  • @nick2874
    @nick2874 5 месяцев назад

    Having trouble setting up using teleport. Any guides for setting up remote debugging through teleport? Using VS Code, Remote SSH via tsh

  • @joshuauzzell541
    @joshuauzzell541 Год назад

    Extremely useful!

  • @solar75wind
    @solar75wind Год назад +1

    Thank you, Derick!! But why did you have to use SSH FS instead of the standard Remote-SSH extension in VS Code? This setup is complicated with the PHP web server.. why not just use the main Apache webserver? It seems to me that the best way to approach this subject is to describe the setup for the most generic versions of the webserver, ports (e.g. 9003), and extensions.

    • @DerickRethansXdebug
      @DerickRethansXdebug  Год назад

      In this case because this is a new feature in vscode's xdebug adapter, which does more than just SSH FS right too, and I had to verify that. I usually use PHP's built in webserver for testing as it's so much easier to setup than Apache, which I never use, not even in production. I'm a ngix user.

    • @solar75wind
      @solar75wind Год назад +2

      @@DerickRethansXdebug Facts: 1. Most PHP-based production environments run on Nginx, or Apache, or Apache with Nginx reverse proxy, and not on PHP webserver. Most development environments try to be as close as possible to the production environments. 2. VS Code comes with its standard Microsoft-published extensions for remote development: Remote Development, Remote - SSH, and Remote - Tunnels. In your earlier videos (or site documentation) your relied on these Microsoft extensions. If they should be avoided, it is important to explain why. 3. Most developers sit behind corporate or home-based firewalls that block the port 9003... Therefore, to help the most developers set up Debugging Remote Code with XDebug 3 and VS Code, it seems to me that the above-mentioned three facts need to be addressed - again, to make this video the most helpful to the real world developers.

    • @solar75wind
      @solar75wind Год назад

      @@DerickRethansXdebug Please do not get me wrong - your work is very much appreciated. You obviously would like to make it useful and helpful to the greatest number of people. In my opinion, it is therefore the wisest approach to start with the least common denominator, a foundational video (based on the most basic and most common development environments), and then build new videos on top of it... I suggest considering remote debugging as the DEFAULT focus of Xdebug since most PHP developers have to deal with remote development and production servers, and a local development server is just a narrow simplified case of the remote development setup... also, can I request a NEW XDEBUG FEATURE? The current Xdebug error output is in red-orange colors and it scares non-technical people very much and inconveniences some of the aestehtic-minded developers... the only solution right now is to use the TamperMonkey Chrome extension to override the default Xdebug colors... is it possible to make the colors configurable or perhaps introduce some color schemes? Certainly, this would be a very welcome new feature for great many people who prefer to customize their development environments... Many thanks!!

    • @DerickRethansXdebug
      @DerickRethansXdebug  Год назад

      @@solar75wind I happen to like the bright orange :-) - I did consider at some point to make these configurable through settings, but instead I have added CSS classes to all elements so that you can use CSS to style them as you like. If you'd like to suggest some colour schemes, I'd be happy to have a look though. File a feature request at bugs.xdebug.org ?

  • @lookus69
    @lookus69 Год назад

    its a great idea to debug remotely, but this didnt work for me! :(
    without setting the pathmappings, the xdebug log shows its trying to find the file in the server with the 'ssh://servername' prefix (just like you show in the video) but when i add the mapping right like you did: "server local path":"ssh://servername/path" xdebug is able to find the right file, but then the vscode tries to find the file locally, appending the 'ssh://path' to the local file sistem like: "Program Files/VSCode/ssh:/servername/path"
    i dont know what else to try! is there any way to make pathmappings one way?

  • @devtiagofranca
    @devtiagofranca Год назад

    thank you very much

  • @JohnnySkVideos
    @JohnnySkVideos Год назад

    Thanks!

  • @solar75wind
    @solar75wind Год назад

    DERICK, I discovered a bug in Xdebug plugin - it doesn't communicate with Xdebug properly when xdebug.client_host is set. It only starts to work correctly when xdebug.discover_client_host = 1 is set. Perhaps this is not a bug but it needs to be explained better because in my case I spent several days digging through things...

    • @DerickRethansXdebug
      @DerickRethansXdebug  Год назад

      This is unlikely to be a bug, and just related to your specific setup.

    • @solar75wind
      @solar75wind Год назад

      @@DerickRethansXdebug DbgpClient worked just fine right from the start, without any issues. But the VS Code IDE listened and would not receive any information from Xdebug. Only when I enabled xdebug.discover_client_host = 1, it started to work correctly just like DbgpClient.

  • @user-up6gg9pl2l
    @user-up6gg9pl2l 22 дня назад

    sir can you make 'launch currently open script' for docker

  • @shawnz9833
    @shawnz9833 Год назад

    Hi Derick, Great content as always, I am following your xdebug 3 videos, I am currently on Xdebug 3 Profiling: 3. Analysing Data, which one I want to watch the next? Could you please index/reindex your great contents to help newbies like to follow your materials better?

    • @DerickRethansXdebug
      @DerickRethansXdebug  Год назад +1

      There isn't really a specific order as I'm just making them as I see fancy. Which ones have you seen so far? I might be able to suggest the next few then. I do want to make a more coherent "course", but that's still in the planning phase

    • @shawnz9833
      @shawnz9833 Год назад

      ​@@DerickRethansXdebug I want to watch the ones after callgrinds. Want to learn more about profiling and run-time analysis. Again thank you for the awesome materials!

  • @borjovsky3164
    @borjovsky3164 Год назад +1

    your mic volume is REALLY low...

    • @DerickRethansXdebug
      @DerickRethansXdebug  Год назад

      I'm sorry, I don't know what happened. I think it must have picked up the wrong hardware microphone.

  • @petruciucur
    @petruciucur 20 дней назад

    Very low sound level