Add containing folder to project in PhpStorm

276 views Asked by At

I'm developing a plugin for Moodle and created a project inside my Moodle installation. I'm extending a class called block_base but PhpStorm says undefined class block_base. My guess is that is because all the moodle files (including the class block_base) aren't in the project files.

How do I add this to the project files? I could just simply make the entire Moodle installation the project but I don't want that because i'm using GitHub and I then have to put all of the Moodle files on there as well and that is just pointless.

1

There are 1 answers

2
davosmith On BEST ANSWER

PHPStorm can handle multiple git roots within a single project (this is how I manage my plugins).

So, you can do the following:

  1. Check out a copy of the main Moodle repo (from [email protected]:moodle/moodle.git)
  2. Put your plugin (including the .git subdirectory) in the correct place in the Moodle code
  3. Set the whole of the Moodle code as the project for PHPStorm
  4. Go to File > Settings > Version Control
  5. Usually PHPStorm will (at the bottom of the dialog) display a list of detected git roots and you can just click 'Add root'. If not, click on the '+' on the right and add the path for your plugin.

Now, you can make changes to your plugin and update, without having to check in a full copy of Moodle (as an added bonus, it makes it nice and easy to pull the latest Moodle code, so you can test your plugin against upgrades).