![]() The thing with WSL2, at least in its current form is that the IP range will totally change during reboots. Notice how we need to give Windows IP address to XDebug so that it can connect back to PHPStorm. It will identify our PHP installation and also tell us that Xdebug is available. We set the CLI Interpreter to use WSL.Under File>Settings>Languages & Frameworks > PHP: # xdebug.remote_log=/var/log/xdebug/xdebug.log Setting Up PHPStormįirst, we configure PHPStorm to use XDebug. Zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so" You can also uncomment the last line and create the path to the log file if you need to debug this further: You will need to modify the zend_extension path to point to your installation of XDebug. So this is what XDebug configuration looks like inside our php.ini file. 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. You can take a look at the packets being transmitted in Wireshark and see what goes wrong. I did not get into debugging why that does not work. 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’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: To do that, we need to setup remote debugging for XDebug so that PHPStorm can connect to it and set breakpoints, show variable values and step through the code. So the idea is to write PHP code in PHPStorm on Windows and run and debug PHP code on Ubuntu over WSL2. On the Windows side, I have installed PHPStorm. On my Ubuntu on WSL2, I have downloaded and compiled PHP 7.4.4 along with XDebug 2.9.3. After following a tutorial 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. You need a build later than 18917 to enable WSL2. ![]() I’m running Windows 10 Education build 19041.172. Environment Informationīefore we go any further, it is wise to discuss what my current setup is. 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. One week in, I’m satisfied with my decision. Specifically with WSL2 and native Docker support, I thought this would be the perfect time to give them a try. After some digging, I finally decided to go back to Windows. I soon noticed that my accessories and their drivers work nowhere near as smooth as they do on my Mac. ![]() But then I had to move my computer home because of all this WFH stuff. I’ve been using Ubuntu for the past couple of years. Let me start by telling you how I got here. Moreover, Docker is now fully supported making development much easier. It’s super easy to work with files from both Windows and Linux and it is much quicker than WSL 1. 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. In VSCode you'll need to install the PHP Debug extension, configre it, and then you should be able to set breakpoints in your code.īe sure to enable the helper and listener in your IDE.2.3 Using X11 Forwarding (Everything Runs on Linux) ![]() ![]() If you are using PhpStorm, setting up Xdebug is straightforward. In Chrome it's Xdebug helper, in FF it's Xdebug helper for Firefox. In order to debug the web application, you'll need a browser extension. You can use Xdebug to debug your CLI scripts (tests for instance), or debug your web application. To prevent this, just make sure you delete it every once in a while, or simply don't enable logging. Possible side effectsĪ possible side effect of running Xdebug, especially if you enable profiler output in Xdebug settings in php.ini, is that the file can grow very large. Now you can install Xdebug again, and it should work as described in the previous case (follow the steps described above to add it correctly into your php.ini). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |