11

I am currently working on a PHP project that uses composer to manage 3rd party dependencies. This project has an /installer subproject which, like the name suggests, contains a small tool that handles the installation and initial configuration of the "main" project. The installer tool also uses composer to handle its dependencies, which are kept separate from the main project's libs.

For convenience reasons, these two projects go into the same git project, and as such in the same PHPStorm project. As both projects dependencies sometimes overlap, I often get a "Multiple definitions exist for class" warning. While this is neither unexpected nor a major issue, I would like to know if there is actually a way to tell PHPStorm "hey, treat everything inside /installer as an independent project, and don't cross-check classes with the outside scope`.

Thanks

2
  • 1
    This is sort of relevant to my interests; it can be annoying especially if you like to have access to branches or tags within your project as well. Commented Dec 7, 2015 at 9:05
  • and why not make them 2 separate projects in phpstorm? Commented Dec 7, 2015 at 9:13

4 Answers 4

6

You can disable this inspection (works for at least PHPStorm 9.0 or later):

Settings -> Editor -> Inspections -> PHP -> Undefined -> Undefined class

Uncheck Options (right bottom) -> Don't report multiple class declaration potential problems

Sign up to request clarification or add additional context in comments.

3 Comments

Disabling diagnostics instead of dealing with them is a harmfully wrong anti-solution.
this is definitely not the solution for the problem....
After update PHP strome to latest version i got "Multiple definitions exist for class " . Follow this steps and its bit different in new update. Settings -> Editor -> Inspections -> PHP->Undefined Symbols -> Multiple class declarations. and untick it. But its actually not good to hide issues
5

It is possible to mark directory as Excluded, so PHPStorm will just hide it and stop index files inside, so no warnings. But in the same time it will be impossible to view (read) that files.

Right click directory (in your case /installer) in Project pane and choose Mark Directory As -> Excluded

4 Comments

That's not what I want, I want to be able to edit both the main project and the installer project.
@tiagojsag: You can open them as separate projects - and with this, each will have its own settings, so they won't interfere with each other.
while this is not what I initially had in mind, I am testing it right now and it seems to work. I will report back after I have used for a few hours, see if there are any downsides to this approach.
The instructions to do this in more recent PHPStorm versions are a little different, but this remains the correct answer.
5

You can right click the files in the Project Explorer and mark them as "Plain Text", so these classes are not interpreted as source code.

The better way: Use Namespaces

1 Comment

Since this bug is still open, this is a good temporary solution.
0

You can delete duplicate declared libraries

Settings -> Languages & Frameworks -> PHP -> Include Path

See image

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.