![]() ![]() Enabling X11 on Windows and running PhpStorm inside WSL2 as a Linux app.“Remote Development” in PhpStorm 2022.3 , which has explicit support for WSL2 and actually runs a PhpStorm instance on WSL2.PhpStorm is slow to index files but can be slow to respond to file changes in this mode, although it’s adequate for many people. Run PhpStorm in Windows as usual, opening the project on the WSL2 filesystem at \\wsl$\ (e.g.It’s possible to use PhpStorm with DDEV on WSL2 in at least three different ways: Enable Xdebug if you want to debug tests with ddev xdebug on.Interpreter: “web” (the one we set up).Test scope (as you wish, by directory or class or whatever).Open Run/Debug configurations and use “ ” to add a PHPUnit configuration.Choose “Path to phpunit.phar” and use /var/For example, for Drupal 9, ddev composer require -dev -with-all-dependencies drupal/core-dev:^9 and ddev composer require -dev phpspec/prophecy-phpunit:^2.Under “Test Frameworks” click “ ” to add PHPUnit.This assumes you’ll need to use PHPUnit and you already have it installed. Configure composer under PHP → Composer.So in this example, the “Local Path” is /Users/rfay/workspace/d9 and the “Remote Path” is /var/www/html: Add an entry that maps your project location to /var/www/html. ![]() In the main PHP setup dialog, add an entry to the path mappings, as it doesn’t correctly derive the full path mapping.In the CLI interpreter “Lifecycle” select “Connect to existing container”.On macOS, you may need to use ⌘ SHIFT . Now back in the “Configure Remote PHP Interpreter” for “Configuration files” use.So “Virtual Machine Path” would be /var/www/html and “Local path” would be something like /Users/rfay/workspace/d9 (on macOS) or \\wsl$\Ubuntu\home\rfay\workspace\d9 on Windows using WSL2. In the “Path mappings” of the “Server” you may have to map the local paths (which on WSL2 means /home/.) to the in-container paths, especially if you have Mutagen enabled.Create a “server” Choose the appropriate Docker provider configured above under Build, Execution, Deployment → Docker.Use the “ ” to select “From Docker, Vagrant, VM…”.Under File → Settings → PHP (Windows) or Preferences → PHP (macOS), click “…” to the right of “CLI Interpreter”.(All you have to do here is click the little telephone to “Start listening for PHP Debug Connections”, run ddev xdebug on, and visit a web page and choose the correct mapping from host to server.) This will result in a PhpStorm “Server” with the proper name, normally the same as the FQDN of the project. Set up your project to do normal Xdebug, as described in the Step Debugging section.Under Build, Execution, Deployment → Docker, set the correct Docker provider, for example “Colima” or “Docker for Mac”.(If you’re running PhpStorm inside WSL2, there are no special instructions.) In other words, in the Open dialog, browse to \\wsl$\Ubuntu\home\rfay\workspace\d9 (in this example). If you’re on Windows, running PhpStorm on the Windows side but using WSL2 for your DDEV project, open the project as a WSL2 project.In this example, the project name is “d9” and the site is “d9.ddev.site”. Start your project by running ddev start.If you’re not using the DDEV Integration Plugin, you can follow these steps instead: Install and enable the plugin, then set up phpunit since it doesn’t yet handle that for you. The integration plugin handles nearly everything on this page automatically, and works on all platforms. It’s easiest to use the DDEV Integration Plugin, which you can install from its landing page or by searching the in-app marketplace ( Preferences → Plugins → Marketplace) for “DDEV”. If you’re using WSL2 and running PhpStorm on the Windows side, PhpStorm can’t use docker-compose from WSL2, so configure Docker Desktop in Settings → General to “Use Docker Compose V2” and use a recent version of Docker Desktop. ddev/bin/docker-compose file relative to your home directory. In PhpStorm, navigate to Preferences → Build, Execution, Deployment → Docker → Tools, and set the docker-compose executable to the full path of your. Regardless of your setup, you need to have PhpStorm use DDEV’s private docker-compose executable. Make sure to get at least one project going with ddev start before trying to set up the plugin, because the plugin assumes it has a project to work with.If you work with the PhpStorm IDE, you can configure it for tight integration with DDEV and Docker to more easily run actions, access services, enable autocompletion, and enjoy a more convenient development experience. ![]()
0 Comments
Leave a Reply. |