How can I get hold of the Composer object? I'm trying to get the file location of something in an installed package.
https://stackoverflow.com/questions/15714809/get-filesystem-path-of-installed-composer-package says I can get that from the Composer object.
But in Drupal, how do I get the Composer object?
Usually, I'm doing this using ReflectionClass.
Take this example: to load the cacert file which comes inside one of composer packages:

First, locate any class in that package using ReflectionClass.
Secondly, get the package path using dirname bypassing the file name.

Code example:
// Load certificate file.
$reflection = new \ReflectionClass(\GSRequest::class);
$packagePath = dirname($reflection-&gt;getFileName());
$gsRequest::setCAFile(realpath($packagePath . '/cacert.pem'));