Add a New Module
In step five of the Build Tools guide, learn how to add new modules to your site.Discuss in our Forum Discuss in Slack
Next, we'll add a module to our existing
slogan branch using Composer. You should already have a Pull Request open for this branch in GitHub, created in a previous lesson.
This section will be performed from the command line, to prepare your local system.
Navigate to the Code tab of the GitHub repository, then click Code and copy the repository URL:
Open a terminal application and clone the GitHub repository (replace
git clone <github-url>
Navigate to the repository's root (replace
Install dependencies with Composer:
Export local environment variables to define your site name and Multidev environment to easily copy and paste example commands in the next sections (replace
export SITE=pantheon-d8-composer-project export ENV=ci-4
Install a Contrib Module
Use Composer locally to add the Pathauto module as a dependency on the existing
git checkout slogan composer require drupal/pathauto
Note that the dependencies of pathauto, token and ctools, are also installed:
Commit the updated
composer.lockfiles and push your work to the
sloganbranch on GitHub:
git add composer.* git commit -m "Install drupal/pathauto ^1.0" git push origin slogan
Enable the Pathauto module on the Pantheon Multidev environment from the command line using Terminus and Drush:
terminus drush $SITE.$ENV -- pm-enable pathauto --yes
You can use the method described in an earlier lesson to export configuration changes made in the last step or you can do it from the command line using Terminus and Drush:
terminus drush $SITE.$ENV -- config-export --yes
Commit your changes in Pantheon from the command line with Terminus:
terminus env:commit $SITE.$ENV --message="Install and enable pathauto"
Use this process to install any new dependency required by your project. The site should never use Drupal's Extend -> Install new module feature or
drush pm-download, as neither of these techniques modify the
composer.json file. Modules added using these methods will disappear the next time the build artifacts are pushed to your Pantheon Multidev environment. You must use Composer to install new modules exclusively.