Gihan
Gihan

Reputation: 4283

Working with multiple dependent PhpStorm projects

My source files are divided into multiple repositories and they are located in different directories. I've created separate PhpStorm projects for each repository. So I'd like the PhpStorm search functions work across some of the projects. How can get this done? How can I mark dependent projects in PhpStorm?

Note: I've tried making the top folder as "Project Root". But that project root contains many other projects which I don't need so it's little bit inefficient from my point of view.

I've used Netbeans and I can do this by going to project properties and setting include path. I found similar option in PhpStorm at File > Default Settings > Language & Frameworks > PHP and set include path. But PhpStorm search functions/file open doesn't work for the include path.

Or at least how can I open multiple projects in same window.

My PhpStorm info

PhpStorm 2016.2.1
Build #PS-162.1889.1, built on August 23, 2016
Licensed to PhpStorm Evaluator
Expiration date: October 10, 2016
JRE: 1.8.0_76-release-b216 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Upvotes: 1

Views: 4092

Answers (3)

Szczepan Hołyszewski
Szczepan Hołyszewski

Reputation: 3175

Depending on who says it, it is either a MYTH or a LIE that PHPStorm really supports working with multiple projects in the same window.

It allows you to open multiple projects in one window, but it doesn't really support working with them in any meaningful way.

There is no way to indicate which of the many opened projects you have in mind whenever you invoke any operation that involves the notion of "current project". The "current project" choice is immutable for the lifetime of the "workspace": it is precisely the first project that was opened/created in it, and there is no way to mark any other project as current / active / "the one you have in mind".

All supposedly "per-project" configuration settings are in fact the settings of this "main" or "host" project, the first one that was added to the workspace. There is no way to configure anything per any of the further projects that you attached to the workspace later. Those further projects are not first-class citizens in the workspace.

This design has been thus broken since the beginning, and there have been FURTHER breakages that exacerbated this problem. For example, PHPUnit run configurations used to have some awareness of the project in which the relevant phpunit.xml is located, and it was possible, albeit hackily, to customize some configurables per project. This ability has since been removed by developer's conscious, actively user-hostile decision.

Upvotes: 10

mFlorin
mFlorin

Reputation: 486

  • You can also ignore files/folders per project too from the Project Structure window.

Project Structure window

Upvotes: 0

LazyOne
LazyOne

Reputation: 165491

  1. Open your project
  2. Settings/Preferences | Directories
  3. Use Add Content Root button and point to a desired folder
  4. Once settings are saved -- those newly added Content Root(s) will become part of the project and will be listed as additional nodes in Project View.

Basically -- the main project folder is a Content Root by itself; using the above you are just adding additional folders to the project-- they will be treated in the same way as main Content Root.

Obviously, since those extra folders will become part of this project, current project settings will be applied to those folders as well.

PHP | Include paths are for the 3rd party code/libraries which you just use in your project but not edit them.


In PhpStorm 2016.3 (currently in EAP stage) it will be possible to open additional projects as part of the current one. This allows cross-project search/refactoring etc.

Once opened like that .. such additional projects will use settings from current project -- just like additional Content Roots do (basically, a bit easier0to-use version of the above). It will NOT work like NetBeans does where you have a "workspace" and can manage multiple projects with separate settings.

Some links:


I found similar option in PhpStorm at File > Default Settings > Language & Frameworks > PHP and set include path.

Default Settings affect future new projects ONLY -- they do not affect existing projects in any way.

If anything -- it should have been done via just File | Settings (Windows/Linux) or PhpStorm | Preferences on Mac.

But PhpStorm search functions/file open doesn't work for the include path.

Not exactly.

They "do not work" because files from such folders are not intended for editing -- they are just for reference purposes. You still can search/open them .. but you have to use additional options (e.g. in Find in Path it could be including "Libraries" scope; in Navigate | File and similar -- "include non-project files" or so).

Upvotes: 5

Related Questions