[2022.2.3] Composer Actions/Plugins Code Assistance

Not sure where I should ask else:

When specifying a composer action/script, e.g:

"post-package-update": "Namespace\\App::postUpgrade"

and then trying to implement said action:

-> I get no coding assistance, as it cannot find the composer classes. Understandable, as they are not in the vendor folder. Anybody who encountered this and somehow got it working?


Hi there,

Have not used it myself (write a composer actions/script) .. but in general: you need to reference those composer classes somehow.

1. "Settings/Preferences | PHP | Include paths" -- try adding a folder where composer.phar is located (has to have a .phar extension in order to be properly parsed). Folders linked this way are for 3rd party code that is typically located outside of the project (all composer packages you use in the project will also be referenced here).

2. If the above does not work -- try adding a copy of composer.phar somewhere in your project (symlink should also work; will be used by the IDE only so you may keep it in some dedicated/IDE specific folder). The same purpose -- so the IDE can parse the needed Composer classes.

3. Or you could try to require a composer/composer package in your composer.json (so the IDE can parse it just as any other package)... But you would possibly need to instruct Composer to exclude this package from autoloading (so it does not see the same classes again/try to autoload from here and possible conflicts that may arise from it). The downside -- it will be a bit odd to require the whole package for code assistance only; even if it's --dev environment only.


Andriy Bazanov I tried the first one and it already works, just had to copy the composer.phar somewhere so it doesn't include all the projects. Thanks for the hints!



just had to copy the composer.phar somewhere so it doesn't include all the projects.

Not sure what you meant to say here. How it can "include all the projects"...

1. I'm on Windows and the folder where composer is installed ( C:\ProgramData\ComposerSetup\bin ) has 3 files only: composer, compose.bat & composer.phar

2. "Include paths" is an IDE feature -- used by the IDE and not PHP interpreter (does not have any effect during PHP execution). And it's a per project setting.


Anyway, you have it solved, so it's not important.


Please sign in to leave a comment.