Getting details of what is installed from within an application?

14 views
Skip to first unread message

Jason Judge

unread,
Jan 16, 2016, 3:45:27 PM1/16/16
to composer-dev
From within an application, I need to search through the composer packages that are installed, looking for packages tagged in a certain way. The tagging will likely take the form of data in the `extras` element of their `composer.json` metadata. Is there a reliable way to find the data for each installed package and library?

Looking into composer, the `installed.json` file looks like it contains what I need. Are there circumstances when `installed.json` would not be available, or is located in a different place? Can it be assumed from my installed package, that `installed.json` will be available from my package's `src` directory in `../../../composer/`? Actually - no, I realise there is no guarantee of that, since my package could be autoloaded from any location where I am developing or testing it. So to rephrase that question, is there a way to reliably locate the vendor/composer directory (bearing in mind it may not even be called "vendor", which is an assumption even composer does not make).

If the above approach is not possible, then I could get a list of the class roots (`$loader->getPrefixes()` `$loader->getPrefixesPsr4()` and `getClassMap()`) and look for an expected class and method in each of those libraries, but that feels messy and wasteful.

Thanks!
Reply all
Reply to author
Forward
0 new messages