I am trying to debug a Symfony command through phpStorm using xDebug and I am not able to get this working. I should start by saying that I am using Docker. AFAIK everything is properly setup (see images below) but each time I hit the little bug icon (SHIFT+F9) button I end with the following message. This is an important step because PHPStorm assumes that the root directory from the incoming request is the public folder (if using either Symfony or Laravel). Make sure you also choose Xdebug as the debugger and use the appropriate HTTP port.
- Phpstorm Xdebug Not Working
- Phpstorm Xdebug Ssh
- Phpstorm Xdebug Docker Cli
- Phpstorm Xdebug Vagrant
- Php Docker Xdebug Phpstorm
The first time I tried to use PHPStorm with XDebug was - in all honesty - a total nightmare. It didn't help that I was working on a project with a looming deadline, and no matter what I tried, nothing seemed to work.
Now, that was back in the Good Old Days (tm) and things have certainly moved on quite a bit since then.
One of the most helpful tools that JetBrains now offer is the XDebug bookmarklets generator. Right away, this will make configuring the interaction between your browser and your IDE a heck of a lot easier.
When working with Symfony, checking whether XDebug is installed and enabled is as simple as looking at your Web Debug Toolbar. Inside your app_dev.php
(dev) environment, mouse of the PHP icon on the toolbar and you'll see a red or green XDebug badge. If it's green, you're good to go. If it's red, you will need to install and enabled XDebug.
If you're running a Debian / Ubuntu based Linux system, installing XDebug is pretty easy.
And then, restart your web server, e.g.
After that, if you refresh the app_dev.php
page in your browser and mouse over the PHP logo, you should see the XDebug badge is now a friendly shade of green.
Alas, that's not the end of our config.
The next thing you'll need to do is modify your XDebug config file. Now, where this will be located differs depending on your system. Redhat / CentOS do seem to put things in sufficiently different places to the Ubuntu / Debian equivalents. Google is your friend.
In our case, we can edit the file with vi:
And the reason I say that it doesn't matter which we edit (apache2 or cli) in the video is because these folders are symlinked so as not to duplicate the config files.
Regardless of where your config file lies, you will need to add in the following:
Save and exit, then restart Apache (or whatever web server you're running - and if it is nginx, be careful with the ports as 9000 may conflict)
Now that your config is all good, be sure to drag and drop the XDebug bookmarklets onto your browser toolbar for handy use.
Once that's done, head inside PHPStorm and open up the Run / Debug Configurations menu page. (03:50 onwards in the video, if unsure).
Add in a PHP Remote Debug profile.
You'll likely need to add in a new server, so click the Plus symbol, and then give your server a name (I tend to use the IP address of the server here, but feel free to use whatever), and make sure you match the Port number to the one you set up in your XDebug config - 9000 in our case.
Digital EHON Site This site turns the folktales of various countries into a picture book and translates them into various languages in order to offer them to the children of the world. EON Online is a comprehensive e-commerce tool that includes online ordering, real-time account information, reporting and budgeting tools, delivery tracking, and much more. With its simple, intuitive design, EON Online is designed to make purchasing easy and cost-effective. Authorized users have access to EON Online 24 hours a day, 7 days a week. Eon online belepes.
Lastly, be sure to add in the Absolute Path to your project. This is essentially the path on the remote server that maps to your local project files. In our case this is:
Then you can validate your config. This bit never works for me, but it seems to have no negative effects other than that.
Be sure to add in your IDE Key. If you followed my example, that would be PHPSTORM123. I change this from the defaults on the off chance that you somehow put this into production.
All that's left now is to enable Debugging inside your IDE by clicking the little bug icon and adding a breakpoint, then starting the debugger inside your browser via the bookmarklet, refreshing the page and you should be dropped into your IDE at the point when you hit the breakpoint.
Phpstorm Xdebug Not Working
One thing to be aware of - debugging Symfony can be a little messy. There's the entire Framework to get in the way of your code, so if you come unstuck, be sure to check out the How to Optimize your Development Environment for Debugging cookbook article which goes some way to reducing that.
This method works on none Symfony projects also.
In this post, I’m going to go over my short journey to setup my PHP development environment on Windows 10. I will tell you how to setup PHPStorm to debug PHP applications using XDebug and PHP setup over Ubuntu 18.04 LTS on WSL2. I would like to work against the latest version of PHP and compile it myself. At the same time, setting up extensions and compiling PHP itself on windows is not a very straightforward task as far as I know. The plan is to have the development environment run from Linux (WSL2) while the IDE, which is PHPStorm in our scenario execute from Windows. This way I can make use of the “user friendly” parts and beauty of Windows while still running and debugging my code on Ubuntu.
The significant point about WSL2 is that Windows has now switched to full virtualization to run Linux with a good level of integration between the two operating systems. It’s super easy to work with files from both Windows and Linux and it is much quicker than WSL 1. Moreover, Docker is now fully supported making development much easier.
Let me start by telling you how I got here. I’ve been using Ubuntu for the past couple of years. But then I had to move my computer home because of all this WFH stuff. I soon noticed that my accessories and their drivers work nowhere near as smooth as they do on my Mac. After some digging, I finally decided to go back to Windows. Specifically withWSL2andnative Docker support, I thought this would be the perfect time to give them a try. One week in, I’m satisfied with my decision. But this new setup came with its own set of challenges that I’m going to discuss in this post and share my solutions with you.
Environment Information
Before we go any further, it is wise to discuss what my current setup is. I’m running Windows 10 Education build 19041.172. You need a build later than 18917 to enable WSL2. After following a tutorial[like this one]to enable this feature, which includes joining the insider preview program (which is free), you would need to setup something like Ubuntu 18 from the Windows store.
On my Ubuntu on WSL2, I havedownloaded and compiled PHP 7.4.4along withXDebug 2.9.3. On the Windows side, I have installedPHPStorm.
XDebug Remote Debugging
So the idea is to write PHP code in PHPStorm on Windows and run and debug PHP code on Ubuntu over WSL2. To do that, we need tosetup remote debuggingfor XDebug so that PHPStorm can connect to it and set breakpoints, show variable values and step through the code. I’m going to steal this Gif from XDebug website to show you how this is going to work, understanding this architecture helps you with debugging if you run into an issue during this step:
There is also an option to have XDebug identify the IP address of our IDE through the initial HTTP request (xdebug.remote_connect_back) but unfortunately it does not work under our current setup. I did not get into debugging why that does not work. You can take a look at the packets being transmitted in Wireshark and see what goes wrong. I suspect because both of the machines are running on the same network and some weird translations are being performed by WSL2, maybe the Ubuntu sees Windows host packets as if they are coming from 127.0.0.1. So this is what XDebug configuration looks like inside our php.ini file. You will need to modify the zend_extension path to point to your installation of XDebug. You can also uncomment the last line and create the path to the log file if you need to debug this further:
Setting Up PHPStorm
Phpstorm Xdebug Ssh
First, we configure PHPStorm to use XDebug. Under File>Settings>Languages & Frameworks > PHP:
Phpstorm Xdebug Docker Cli
- We set the CLI Interpreter to use WSL. It will identify our PHP installation and also tell us that Xdebug is available.
- Under Debug, we enable Xdebug and also uncheck the “Pass required config options through command line” under Advanced settings. (This option will pass XDebug configurations through the CLI and override the configurations we have in php.ini)
- Finally, to run our script, we need a Run/Debug configuration. Notice that we set interpreter options to“-dxdebug.remote_host=wsl2.host”. This is where we tell XDebug what our IP address of the Windows host machine is, to get that debug connection back. Keep this detail in mind, we’ll get back to it.
Phpstorm Xdebug Vagrant
Windows WSL2 IP Address
Notice how we need to give Windows IP address to XDebug so that it can connect back to PHPStorm. The thing with WSL2, at least in its current form is that the IP range will totally change during reboots. Let’s say the IP range of the network of WSL2 is currently in the range of “172.30.0.1″, the next time you reboot the machine, and its gonna happen with a Windows machine, the IP address will be in the range of “172.16.14.1”. So we need a way to identify this IP address after each reboot. Ideally, a dynamic entry in hosts file that will map“wsl2.host”to this IP address. This way, we don’t have to update our PHPStorm configuration with the correct IP address every time.
Php Docker Xdebug Phpstorm
My solution is to run a .Net Core application after each reboot. This small application will read the new IP address of Windows WSL2 interface and update the hosts file entry accordingly. The source code is available here:https://github.com/silverfoxy/wsl2_host_ip.
Download therelease buildof this program. Put it under “Program Files”, and create task under Windows Task Scheduler to run this program withelevated privileges (To update the hosts file) after each login and the action is to run a program which points to our executable.
Now this will add an entry to the Windows hosts file named “wsl2.host“. Recall that we used this host name earlier in our PHPStorm configuration that is passed through the command line to XDebug so that it can connect back from WSL2 Linux VM to our Windows host machine.
This way, we can use our setup and develop PHP applications on Windows while debugging them against the latest version of PHP on Linux. You can verify this by setting a breakpoint in PHPStorm and the breakpoint should pause the execution. Yaaaay!!
Using X11 Forwarding (Everything Runs on Linux)
There is also an easier way to do this which I briefly introduce. The idea is to use X11 forwarding, install everything (PHP, XDebug, PHPStorm) on Linux and just use the UI on Windows. This also works well, and was not perceivably slower. It feels like the fonts are rendered slightly pixely, but I’m not sure if this is truly the case or just a bias between Windows and Ubuntu fonts for PHPStorm. But after all this is an easier setup. I usedVcXsrvfor X11 forwarding on Windows and it works well.
Читайте также
- SSH into mobylinux (docker for windows)
#based on po75558Manuel Patrone comment on https://forums.docker.com/t/how-can-i-ssh-into-the-betas-mobylinuxvm/10991/8#get a privileged container with access to Docker daemondocker run --privileged -it --rm -v…
- Portainer on Windows 10
Piggyback truck for sale. Here I have 2 methods for running portainer on windows, a quick, preferred method only requiring a fairly recent version…
- Анализ ошибок с XDebug и PHPStorm
XDebug это отличный php-модуль для правильного дебага приложения, который в «старших» языках (читай - не интерпретируемых) уже сразу был встроен в компилятор.…