Detect installation via this plugin
Hello, is it possible to reliably detect from inside a library that it was installed in a special way through this plugin and not as a normal require-dev dependency? Thank you.
Hi, at the moment I don't think so. Maybe it would be possible by adding an environment variable before executing the installation?
Coming back to this: is there any reason for this? Because such a library would not be any different from another. It just comes from a different directory but it's not installed in a special way
What I need to detect is this situation:
vendor/
// Symfony 6 instaled here
vendor-bin/
// PHPStan installed here
// Symfony 4 installed here because of another dependency
Because people sometimes install PHPStan like this even if there's no othe reason, and because PHPStan looks around its vendor directory to see the dependencies used in the analysed project, with this structure it will think the project uses Symfony 4 and not Symfony 6.
Do you have any tips for me? :)
PHPStan looks around its vendor directory to see the dependencies used in the analysed project
Is it a behaviour specific to when PHPStan is installed as a package instead of being used as a PHAR?
PHPStan is installed as a package in vendor-bin. PHPStan is always distributed as PHAR, even in the phpstan/phpstan package.
would providing an environment variable be enough here?
Erratum actually that would not work since what you want is to check afterwards.
I think in 99.99% of the cases, you can check for the path (root/vendor-bin/namespaceName/{vendor, composer.json, composer.lock}).
There is a chance someones changes the path via https://github.com/bamarni/composer-bin-plugin#change-directory, but honestly not sure what you can do here...
If you have any idea I'm open to it though.
When "bin-installed" by bamarni/composer-bin-plugin the parent directory of the current bin/ (thus the "non-bin" vendor directory) has no phpstan/phpstan subdirectory.
@ondrejmirtes is working out via the file directories good enough or you think something else should be done there?
Yes, it's sufficient, thank you :)