Helper class to locate a Drupal installation from a given path.
Drupal Finder provides a class to locate a Drupal installation in a given path.
$drupalFinder = new \DrupalFinder\DrupalFinder(getcwd()); $drupalRoot = $drupalFinder->getDrupalRoot(); $composerRoot = $drupalFinder->getComposerRoot(); $vendorDir = $drupalFinder->getVendorDir();
If a set of environment variables is specified, then Drupal Finder uses those values to determine the paths of the pertinent directories:
This is useful for situations where you are containerizing an application, directories may be in odd places, or a composer.json might be missing since it is unneeded in a final build artifact.
You are not required to set all the environment variables to use this feature. If you set an environment variable, then its associated getter function will return the value assigned to the environment variable.