webflo/drupal-finder

Helper class to locate a Drupal installation from a given path.

Installs: 33 200 976

Dependents: 259

Suggesters: 0

Security: 0

Stars: 126

Watchers: 6

Forks: 24

Open Issues: 23

1.2.2 2020-10-27 09:42 UTC

README

GitHub Workflow Status Packagist

Drupal Finder provides a class to locate a Drupal installation in a given path.

Usage

$drupalFinder = new \DrupalFinder\DrupalFinder(getcwd());

$drupalRoot = $drupalFinder->getDrupalRoot();
$composerRoot = $drupalFinder->getComposerRoot();
$vendorDir = $drupalFinder->getVendorDir();

Environment variables

If a set of environment variables is specified, then Drupal Finder uses those values to determine the paths of the pertinent directories:

  • DRUPAL_FINDER_DRUPAL_ROOT
  • DRUPAL_FINDER_COMPOSER_ROOT
  • DRUPAL_FINDER_VENDOR_DIR

For example:

  • DRUPAL_FINDER_DRUPAL_ROOT=/var/www/web
  • DRUPAL_FINDER_COMPOSER_ROOT=/var/www
  • DRUPAL_FINDER_VENDOR_DIR=/var/www/vendor

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.

Examples

License

GPL-2.0+