I am trying to set up PHPStorm as an IDE for doing Drupal 10 development on a Windows 10 PC.

I've successfully downloaded and installed PHPStorm from PhpStorm-2023.2.3.exe, and it starts up wth a "Welcome" page when I click on its icon in the Windows 10 GUI. But it only let me open up a Project (new or old one). I have found no way to configure what version of PHP to use, to set it up to install the Drupal core and extensions with Composer, or configure it to work on a custom Drupal extension that makes use of Symfony and the Drupal API.

I am a Gnu/Linux person that feels at home using the CLI – and that MS Windows 10 and its GUI is an alien environment to me, so please bear over with my confusion. However, I understand that PHPStorm must be used from the GUI. It simply is not designed to work from the CLI, so if I want to use it, the CLI is not an option.

Are there any tutorials on setting it up for using it for Drupal 10 development? Any guidance will be appreciated.

Comments

fkelly12054@gmail.com’s picture

To start with, 1. do you have a copy of Drupal working on Windows?  And (2) do you have Composer working from the command line in Windows?  If not, you may need to get composer working on windows, then use it to install a Drupal site in some directory.  When I "composerized" my sites, I put successive versions in a series of directories ... say d:\compa, d:compb ... etc, until I had tweaked my composer.json to have the core version,  modules (and vendor directory) that I wanted to use.  In PHPStorm you also use the settings to tell it which PHP version to use. There are quite a few things you have to set up through PHPstorm settings.  Xdebug for instance.  You'll see them in File/settings once you have a project set up in PHPstorm.

You'll also want to get Drush working from the command line in a terminal window ... that can take a bit of tweaking around to get the right executable in your Windows path.  With the correct composer.json, composer will load Symfony in the right path to work with Drupal core.  

So yeah, you will be using both Composer and Drush from the CLI, pretty much like you did with Linux.  The Drush instructions are confusing, especially if you are not familiar with Windows paths.  But eventually, (soon in your process) you'll want to have it working.  I can help a bit with that since I have an environment like that working.  You'll find that Composer overwrites your files when you do the monthly version update.  You will also find, I think, that the PHPstorm file history that's built in is very handy when you are making changes.  I'd also recommend getting a backup program running against whatever project directory you have your Drupal site running in.  That way if somehow the project directory gets corrupted (it's happened to me once in 2 years) you have something you can restore.

Not sure which development environment you are planning to use.  I use Wampserver but then again I'm a dinosaur.  I see a lot of recommendations for ddev but haven't set aside the time to explore that option especially since Wampserver is working just fine.  I can "mirror" my Wampserver based site almost exactly against my hosted (Inmotionhosting) site and test all updates locally before replicating the process on the hosted site.  

gisle’s picture

1. do you have a copy of Drupal working on Windows?

No.

And (2) do you have Composer working from the command line in Windows?

No.

I had hoped that when installing the PHPStorm IDE on my local Windows 10 PC, "integrated" implied that it came as turnkey development environment with everything I needed ready to be installed. Apparently not.

From your answer I understand I need an development environment in addition to PHPStorm. If so, it looks like DDEV with Xdebug is the best option today. I have found this page in the Drupal documentation Wiki: Configuring PhpStorm, which starts out by saying:

For full documentation on using PhpStorm and Drupal, refer to the JetBrains documentation.

However, the JetBrains documentation simply says:

Download Drupal from the Drupal Official website and install it as described in the Drupal installation instructions.

I am familiar with the  official instructions for installing Drupal and know that it requires Composer, which is not yet set up on my Windows PC (but which I understand will be there eventually, as part of the target development environment). So I continue with Configuring PhpStorm, which says:

Setting up Xdebug in DDEV is extremely easy. Open PhpStorm and then:

  1. Install the DDEV Integration Plugin via Preferences → Plugins → Marketplace
  2. Enable "Use Compose V2" under Build, Execution, Deployment → Docker → Tools

But when I open PHPStorm, there is no "Preferences" to be found. There is "Plugins", with a "Marketplace" tab, but no "Build, Execution, Deployment" anywhere to be seen, and I find no way to enable "Use Compose V2".

Since a lot of people use PHPStorm to develop Drupal extensions, I am sure that this is very feasible. But at the moment, I feel very lost by not finding any documentation about setting this up that I am able to follow.

- gisle

fkelly12054@gmail.com’s picture

Looking in my PHPstorm settings (NOT PREFERENCES) I can see the DDEV integration plugin.  I think the documentation is just wrong in this case.  Debug shows up under Settings PHP Debug ... I suspect ddev might give you another option for loading xdebug.  For xdebug I just follow the instructions on the PHP settings screens for PHPstorm.  I also install a Chrome extension for xdebug.  To run debug I just have PHPstorm listen for xebug and activate the Chrome extension to enable xebug.  That's cool because I can just go to the part of Drupal that's giving me trouble and activate it there rather than xdebugging the whole mess.  

For my paths in Windows environment variables I have:

c:\ProgramData\ComposerSetup\bin and

d:\webpage\compg\vendor\drush\drush

Your specific paths will vary from those but you'll want something in the path.

I run Chrome as a separate application.  You kind of need Chrome for any phpunit testing because you need Chromedriver and you need to have a Chromedriver version that's up to date with the version of Chrome you are using.  I installed Composer separately from PHPstorm.  I suspect that if I used ddev I might have to (or want to) do what you posted.  i.e., Build, Execution, Deployment → Docker → Tools

edit:  Phpstorm is really a brilliant and comprehensive tool for developing Drupal Code.  Once it scans your Drupal project it knows a lot about your Drupal site and can provide a lot of help avoiding errors.

ressa’s picture

I haven't use PhpStorm for a while, and also couldn't figure out where the Build, Execution, Deployment → Docker → Tools enable "Docker V2" was supposed to happen ... It looks like it is no longer necessary, and I have updated the Drupal/DDEV/PhpStorm doc page to reflect this.