Preamble
This issue has a limited scope related to the file system layout of Drupal and how that interacts with Composer behaviors.
The reason for this limitation is so that it is a thing that can be understood, evaluated, and accomplished.
Problem/Motivation
We currently have some contradictory ideas about how to use Drupal with Composer.
Here we see people wanting to use Composer to manage their Drupal site:
#2477789: Use composer to build sites β
(to the point that they want to stop offering a tarball:
π±
Stop offering .tar.gz downloads
Closed: outdated
)
Here we see people wanting to not ever think about Composer at all during their site build:
#2845379: Provide optional composer integration but don't force users to understand how to use composer β
Let's figure out how to combine these two motivations and give everyone what they want.
Currently, Drupal core has a composer.json file in its root.
This composer.json file defines a package called drupal/drupal. In the git repo, there is also a composer.lock file, which specifies the versions of other packages which are known-good.
In the context of Drupal core development, the drupal/drupal package is used to build the codebase for Composer requirements so that development can occur.
In the context of building the Drupal 8 distribution 'tarball', the drupal/drupal package and the composer.lock file are used to build the files necessary for the tar and zip file downloads.
Also of note is the existence of drupal-project. This project uses a lot of special-case code to move Drupal's files around towards the end of, for instance, having a server docroot with no vendor/ directory in it. These are all reasonable goals for Drupal, and are in fact
documented on drupal.org β
.
So, the desired goals are twofold:
1) Use Composer to build best-practices-type sites with isolated docroot and so forth. This has all the advantages you can learn about from talking to the drupal-project maintainers.
2) Leave Drupal like it is so that it can be used on cheap shared hosting by 'non-experts' who can't reconfigure a web server doc root (either due to lack of skill or because their hosting forces them, or whatever else). This has the advantage of leaving Drupal as an entry-level site building tool for people who want to host their own site but maybe aren't technical experts.
We have an existing solution for goal 1: drupal-project and other bespoke solutions. The problem with these out-of-core solutions is that they are inconsistent and confusing to someone who is new. Why would they choose drupal-project or whatever? They don't know. And the reason they don't know is because they are the target audience for goal 2.
If we were to make it so that drupal-project were not necessary, this would make many expert users happy. They could composer require
all day long and be content. There would be no need for drupal-project maintainers to chase down special cases added to core, and accordingly, no need for site builders to wonder what process errors will be introduced in the next minor update.
And if we made it so that drupal-project were not necessary, then we would also make it easier to deal with distributions. Distributions would truly become a Composer-based build.
And guess what? One of our distributions could be the d.o tarball as we know it now. Let's name it drupal-tarball-project
.
Here are some requirements for our design process:
- We must end up with a tarball similar to the existing one. That is, we must have a way for people to use a tarball to install Drupal without changing the server docroot.
- Installing/updating/uninstalling a module must be the same process for all modules, regardless of their Composer needs. This could also include their need to build out JS or CSS.
- [ Add Yours Here ]
User stories
From @webchick #30:
"When I install any contributed module, I should be able to take exactly the same steps. Whether the maintainer chose to manage their dependencies in .info files or Composer is an implementation detail based on their own personal preferences, and should be utterly irrelevant to me as a site builder."
The most common ways of installing contrib modules are (I believe, in this order):
- Downloading the tarball and sticking it in /modules.
- drush dl/en modulename
- Using the Update Manager UI
Proposed resolution
We have a few general solution ideas:
- Originally proposed in this issue: Invert the file structure of Drupal core. Change the core repo so that it has a web/ (or other name) directory where index.php lives, and the remainder outside of that. Then use a Composer project to build the tarball distribution.
- #35: Create a build tool which users can run locally to build their Drupal. This would include a Composer dependency build phase. It could also do things like build your SASS and so forth.
- #37, #38: Similar to the build tool idea, the build process would live on drupal.org. You'd give a set of requirements and d.o would then send you a tarball which it built for you.
Remaining tasks
User interface changes
API changes
Data model changes