Problem/Motivation
Drupal does not have a standard Composer package name policy (that I am aware of). Because of this, we could encounter a scenario in which Composer package names conflict (we kind of already are).
For instance, in core/lib/Drupal/Component/README.txt it says:
In other words, only dependencies that can be specified in a composer.json file of the Component are acceptable dependencies. Every Drupal Component presents a valid dependency, because it is assumed to contain a composer.json file (even if it may not exist yet).
In #2176065: Introduce a composer.json for Drupal\Component\Utility a composer.json
was added that uses the package name:
drupal/utility
which makes perfect sense.
Also, in #1975220: Allow a Composer user to manage Drupal, modules, and PHP dependencies with a custom root composer.json , two package names are added:
drupal/core
for Drupal core and:
drupal/drupal
for Drupal proper.
None of these at this point conflict, however, every idea presented in #1886820: Packagist for Drupal Projects (and Commerce's composer.json) uses the pattern:
drupal/MODULE
This also makes perfect sense (especially for projects hosted on drupal.org)
Where things stop making sense is that we have Drupal components that conflict with existing modules:
Diff& Diff
Datetime& Datetime
etc.
Proposed resolution
Composer only allows for package names like so:
vendor/project
You cannot use more than two levels. :(
Drupal already has an existing namespace based on:
https://www.drupal.org/project/PROJECT
because of this, any project (drupal, core, profiles, modules, themes, etc.) should be in this namespace:
drupal/PROJECT
Examples:
https://www.drupal.org/project/drupal becomes drupal/drupal
https://www.drupal.org/project/core becomes drupal/core
https://www.drupal.org/project/datetime becomes drupal/datetime
https://www.drupal.org/project/views becomes drupal/views
etc.
Some of these URLs don't exist, or point to other modules, but Drupal wont let you run two modules with the same name anyways, so that is irrelevant. Also, like in the case of Views, the version numbers are completely different. When #2456009: Add a "replace" section to core/composer.json lands, if you specify drupal/views
as your dependency, that dependency will be resolved with drupal/core
(as it should be). Although, in the future, it might be a good idea for Drupal.org to reserve those namespaces (and preferably post subtree splits to them).
The only problem then, is Components, which are not required to live in the existing Drupal namespace.
These components should be prefixed with their parent's name:
drupal/PROJECT-COMPONENT
Examples:
Datetime becomes drupal/core-datetime
Diff becomes drupal/core-diff
This also allows contrib to expose components like so:drupal/panels-renderer
drupal/ds-builder
etc.
Since the -
(dash) is not used in the existing drupal namespace, it shouldn't conflict in anyway to what is currently in Drupal.
Remaining tasks
- Make a decision Composer package name standard.
- Ensure that existing
composer.json
files meet that standard
API changes
Any composer.json
files that reference the old names will need to be updated. As far as I know there are none in core, but there might be some in contrib already.
Beta phase evaluation
Unfrozen changes | Unfrozen because it really only has implications for the naming of Composer-based packages in Drupal\Component. |
---|---|
Disruption | Potentially disruptive to infrastructure outside Drupal, depending on what's decided. Existing Composer-based build systems might need to rename their packages. |