But, if it does have Composer dependencies, cloning it into the modules/contrib/ directory won’t trigger Composer to install dependencies. In this case, I:Modify the composer.json’s repositories section as follows:I enjoy keeping my Drupal development skills sharp. One of the ways I do this is through code contributions in various contrib projects like Markdown Easy and Smart Trim. In this quicktip, I’ll show you what my typical workflow is when working on a code contribution.
- Create a project-root modules directory.
- Not only will this method gather the project’s Composer dependencies, but it will also symlink the project into your site’s web/modules/contrib/ directory. This method supports having multiple contrib projects cloned in the /modules directory and added to the site’s codebase via composer require.
- I also use this method when teaching people how easy it is to contribute during our weekly DrupalEasy office hours (available exclusively to DrupalEasy long-form course alumni) and just recently realized I didn’t have it documented anywhere.
"repositories": {
"0": {
"type": "path",
"url": "./modules/*"
},
"1": {
"type": "composer",
"url": "https://packages.drupal.org/8"
}
},
AI was not used in the authoring of this quicktip. Clone the contrib project into the new modules directory. Finally, run composer require drupal/project_name (obviously replacing project_name with the project you’re working on.)Often, working on issue forks and merge requests requires a local copy of the project’s Git repository. If the project you’re working on doesn’t have any Composer dependencies, then the process is generally very straight-forward; just clone the project directly into your web/modules/contrib/ (or similar) directory and you’re good-to-go.