In the Drush Configuration section of the official documentation it is said:

drush.yml files are discovered as below, in order of precedence:

  1. Drupal site folder (e.g. sites/{example.com}/drush.yml).
  2. sites/all/drush, WEBROOT/drush, or PROJECTROOT/drush.
  3. ...

There you can see "WEBROOT" and "PROJECTROOT", but there's no explanation on what they are. In the Drush code there's no mention either apart from the configuration itself:

$ grep PROJECTROOT * -r
drush/docs/using-drush-configuration.md:2.  `sites/all/drush`, `WEBROOT/drush`, or `PROJECTROOT/drush`.                                                                                                                                

$ grep WEBROOT * -r 
drush/docs/using-drush-configuration.md:2.  `sites/all/drush`, `WEBROOT/drush`, or `PROJECTROOT/drush`.                 

How Drush determines the values of PROJECTROOT and WEBROOT?

The questions is what those names means, but how Drush decide what they are. If they are used to search for different configuration files it means that Drush resolved those names to actual folders or paths in the current system. How Drush resolves them?

My guess is that Drush takes the root folder of the site (defined ion the Drush alias. If that folder is a Drupal root then WEBROOT and PROJECTROOT are the same, the defined root folder. If the configured root folder has a composer.json and a web folder then PROJECTROOT is the confiugred root path, and the web folder is the WEBROOT... but it is just a guess.

  • 2
    I’d imagine it literally means the root folder of your project vs the folder in your project which contains the web root.
    – Clive
    May 6 at 9:14
  • Yes, that's true. But how Drush knows that? In the alias configuration you define the root path. That could be the webroot, but that's not true because you can point to the folder that contains the composer.json. I guess Drush is intelligent enough to check if the root configuration value is a drupal root (in that case WEBROOT and PROJECTROOT are that folder) or is boilerplate scheme like the one created by composer create-project, so the folder with composer.json is PROJECTROOT and the web folder is WEBROOT... but I would like a confirmation.
    – sanzante
    May 6 at 11:30
  • Yes, drush is clever enough to traverse up the folder structure until it can find something it identifies as a Drupal project root (you'd have to look at the code to get the exact criteria). Similar to how Git, Composer and other tools work
    – Clive
    May 6 at 11:56

2 Answers 2


Drush uses webflow/drupal-finder to determine these directories. The logic is in the DrupalFinder::findAndValidateRoots()

WEBROOT is the Drupal root folder and PROJECTROOT is the folder where the composer.json file is placed.

DrupalFinder is used in several places, but the interesting part is the Preflight::setSelectedSite function.

There Drush locates the "Drupal Root" and the "Composer Root". The "Drupal Root" is... well, the Drupal Root folder and what the Drush documentation calls WEBROOT. And the "Composer Root" is the folder where composer.json file is located and it is what the documentation calls PROJECTROOT.

  • Yes, I understand that, the question is more about how Drush determines the values for those folders. I've updated my question.
    – sanzante
    May 6 at 11:24
  • Updated @sanzante
    – sonfd
    May 6 at 15:39
  • Thanks! That's what I was looking for! I'm updating my question with my findings.
    – sanzante
    May 6 at 17:36

When you download Drupal using Composer, you get directory (folder) with some files. This is the project root, as it is the top-level of the entire project.

However, when viewing a Drupal site through a browser, you are not viewing the project root, rather, you are viewing one directory below it; by default, this folder is called /web (though it can be changed in composer.json). The web folder is the webroot, as it is the top-level folder that is viewed when accessing the project through the web.

  • That's the standard definition of a web root and a project root. I already know that. What I am asking is how Drush determines the value of WEBROOT and PROJECTROOT, not the general definition of web and project root in the context of a web project.
    – sanzante
    May 6 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.