What's wrong with my Composer workflow?

Answered

Hi!

Looks like I misunderstood some concepts of working with Composer in PhpStorm. Here's the case.

I work with legacy application and need to use Twig and PHPWord packages. When I install it ($ composer require <package/name> ) through CLI PhpStorm adds new directories in vendor/ to Settings - Directories - Excluded Folders. And I can not use auto-import and/or auto-complete for those newly installed packages until I manually remove (eg. vendor/phpoffice/phpword) from Excluded Folders. Is it normal behaviour or I need properly setup PhpStorm to not auto-exclude 'main' Composer packages folder?

0
7 comments

How does that "vendor/twig/twig" folder looks in the Project View? -- show a screenshot.

What I may suggest:

  • Create brand new empty project
  • Install Twig (or any other package) via composer and let IDE do the job (exclude folder and stuff)
  • See if it will work for you (I mean -- write some small working code that gets executed with no errors but IDE has issues with it)
  • If still does not work -- please share such whole project (zip whole project folder and share via Dropbox or alike)
  • Also try disabling ALL 3rd party (custom -- not bundled by default) plugins to see if one of them may be creating some interferences
1

Yes please.

1) Close that project in IDE (in case if you have reopening last opened project option enabled)

2) Close IDE

3) Delete that .idea subfolder

4) Open IDE and using "Open" from Welcome screen point to the project root -- IDE will create new project from those files

1

OK, solved! Thanks again!

1

Hi there,

When package's folder that was installed by Composer ("vendor/phpoffice/phpword" for example) is marked as Excluded, then (at the same time) it should be added as "PHP Include Path" entry for the code completion to remain working.

  • The reason for such exclusion is quite simple: it's a 3rd party library that you have no need to edit directly .. or see TODOs from .. or see inspections run on them .. or perform general search (usually you want to search your own code only) etc .. so it's better to exclude from such analysis and stuff.
  • But at the same time -- those files are needed for code completion ... so they are re-added as "external entry" .. which also gives some small protection from accidental modification of such files (it should ask before saving such file) etc.

Therefore -- please check if full path to the "vendor/phpoffice/phpword" folder (for example) is present in "Settings/Preferences | Languages & Frameworks | PHP".

Overall -- this all should be done automatically by the IDE (does it here for me ll the time). Maybe you have not initialised Composer integration yet ... or ignored/declined some popup that was offering to do that? Not sure.. but please check idea.log file (Help | Show Log in...) for possible details (in case if there are some errors there).

0

Thanks, Andriy, for prompt replay! 

But in my case I have all the mentioned directories in PHP Include Path and I can not use auto-completion until removing them from Excluded Folders. I remember that few months ago when I first add Twig to the project I faced with the issue, read documentation, struggle a little with different PHP Include Path and Excluded Folder combinations and decided just remove vendor/twig/twig from Excluded Folder. Tomorrow I started playing with PHPWord package and faced with the issue for the second time. Seems like ... In fact I have no idea what's wrong with my PhpStorm. If it matters I'm on Ubuntu Xenial with the latest PhpStorm installed. 

0

Whoa! It really works great on brand new project with the same set of third-party plugins installed. Looks like I should drop .idea/ folder for the project, shouldn't I?

0

Yeah, I dropped .idea/ folder and re-open project directory in PhpStorm. Now it works OK - it both excluded folders and add them to include path. Thank you, Andriy!

0

Please sign in to leave a comment.