Drupal Commerce on Drupal 8
Use Composer to Install Drupal Commerce with Drupal 8, on Pantheon
This guide covers installing Drupal Commerce, an e-commerce implementation designed specifically for Drupal. At the end of this guide you will have a Drupal Commerce site, GitHub repository, and Circle CI configuration for testing.
Before You Begin
This process uses Composer to manage modules and dependencies. Before proceeding, you may wish to consult the following docs:
As packages pulled by Composer are updated (along with their dependencies), version compatibility issues can pop up. Sometimes you may need to manually alter the version constraints on a given package within the
require-dev section of
composer.json in order to update packages. See the updating dependencies section of Composer's documentation for more information.
As a first troubleshooting step, try running
composer update to bring
composer.lock up to date with the latest available packages (as constrained by the version requirements in
In addition to Pantheon, you will need accounts at:
Follow the Before You Begin section of the Build Tools guide to install Composer, Terminus, and the Terminus Build Tools plugin on your local computer, and create machine tokens for GitHub and CircleCI. Export the tokens to your current terminal session, as described below.
This guide uses several variables in example Terminus commands. This lets you copy and paste without needing to change the variable. For this to work, you must first export the variables in your local terminal session:
export SITENAME=yoursitenamehere export GITHUB_TOKEN=yourgithubtokenhere export CIRCLE_TOKEN=yourcirclecitokenhere
SITENAMEwill be used as the machine names of the Pantheon site and the GitHub repo created in this process
GITHUB_TOKENlets Terminus interact with your GitHub account to create the repository
CIRCLE_TOKENis used to configure CircleCI to push to Pantheon any time a push is made to the GitHub repo
Create a New Drupal 8 Site
Using the Terminus Build Tools plugin, create a new Drupal 8 site from the Pantheon Example Drops 8 Composer repository on GitHub:
terminus build:project:create pantheon-systems/example-drops-8-composer $SITENAME
At this point do not go to the web interface to continue installation.
You now have a repository on GitHub containing your new site. Clone a local copy to your
cd ~/projects git clone email@example.com:username/$SITENAME.git
Remember to replace
usernamewith your GitHub username.
Install Drupal Commerce
Move into the local repository for your site:
Use Composer to install the Commerce Installation Profile:
composer config repositories.commerce_base vcs https://github.com/drupalcommerce/commerce_base composer require "drupalcommerce/commerce_base dev-8.x-1.x"
git statusshould show that the
composer.lockfiles have changed:
Commit the new files and push them to GitHub:
git commit -am "add commerce_base to project" git push origin master
From your CircleCI Dashboard you can see that tests are already being run on your new commit. Once they pass, CircleCI will push the changes to your Site Dashboard.
Go to your newly created Site Dashboard. Under the Dev tab, click on Code, then install later. You should now see your commit history. Once CircleCI completes the automated tests built into our repository, it will commit the build assets and push them to Dev:
The Build Tools Plugin command we used earlier automatically installed Drupal's standard profile in the Dev environment for us. Now that we've installed the Commerce profile, we want that installed instead. Using Terminus, we can run the Drush command
site-installwhich will first clear the database of the Standard profile before installing Commerce. This Drush command requires that the system be in writable (SFTP) mode:
terminus connection:set $SITENAME.dev sftp terminus drush $SITENAME.dev -- site-install commerce
Review the last two lines of output to identify the username and password created:
Installation complete. User name: admin User password: jTHD8hd85U [ok] Congratulations, you installed Drupal! [status]
Log in to your Drupal site in the Dev environment. The presence of the Commerce button on the toolbar indicates a succefull install:
What you do next is up to you and your needs. Remember that you're now using Composer to manage core, modules, and dependencies for your site. Consider reading our Composer Fundamentals and Workflows doc for more information.