CiviCRM Installation in Drupal 8 & Commerce 2
It’s amazing how, just a couple of years ago, Drupal 8 was in its initial stages and was getting ready for its first stable release. But now, in 2018, we have stable releases and contributed module development on D8 has been progressing rapidly (as of this writing, we’re at nearly 5,000 D8 modules). CiviCRM, the best open source customer management tool, is one such community contributed integration that has been making such Drupal 8 strides.
When one of our clients needed their D7 CiviCRM ported over to their new D8 site, the prospects were not good: CiviCRM seemed to be lagging behind and the general online consensus was that things weren’t working, and boy are we glad the internet was wrong. The people behind the open-source content management framework has gotten its D8 version out and interestingly, most of it works beautifully. To our surprise (and relief!), the integration with the D8 site went incredibly well, of course, with a few kinks here and there. Those kinks are primarily due to the fact that Civi ships with its own Symfony version, which is a different version than what Drupal uses and that causes a conflict. For more information on it, read here.
We were able to do our Civi installation by following the steps mentioned in the wonderful blog by David Snopek. So, even though it was a bit complicated, it was definitely a learning experience for us and we thought we would share some of that knowledge here. In this blog we’ll be detailing how to install the richly packed Customer Relationship Management tool called CiviCRM on an existing Drupal 8 Commerce 2 ecommerce store. However, if you’d like to install a new Vanilla Drupal Commerce 8 site with CiviCRM already setup, we’d suggest you follow the easy-to-use instructions in Snopek’s blog.
Steps for Installing CiviCRM (Existing Installation)
In Drupal 8, installing CiviCRM is a bit more complicated than doing just a simple...
$ composer require drupal/civicrm
...like you would for other modules.
If you are waiting for a more standardized policy/process for installing Civi, it might not be in the near future, as the maintainers feel that we already have a process that works and they want to spent their time concentrating on getting the actual module more stable and fixing functional bugs. They also need to come together and agree upon what is the best way to organize the code and do its build. So, the process to get it installed on a D8 installation requires quite a few steps, but if you do it right, it will work.
Below we’ve tried to slim down those steps and made it a bit more concise, so that, essentially, all you would need to do is copy and paste the commands and be on your way to using a fully integrated CiviCRM on top of Drupal 8. It took us a couple of attempts to get it right when we first installed it as some of the steps were in different places and missing a step would mean you had to start over.
Installing CiviCRM on an existing D8 site
- Composer - not just the tool, but your Drupal 8 site should be using composer to manage dependencies.
- Bower - another package management tool. Yes, we are rich with package managers in this process.
- Git - Source control (managing the code that runs your site) is an essential part of every build, but particularly, it’s a requirement of Composer, because it uses that source control to lock down which packages you are building on.
Note: as CiviCRM Core hasn’t been added to Packagist yet, we’ll be using David Snopek’s fork.
- In your D8 installation, ensure that your "Vendor" directory is outside of your document root. So your directory structure would be like this:
└─ web (your document root)
- Create a backup of your database.
- Go to our github repository, civicrm_d8_install_script, and copy the .env and civicrm_setup.sh files to your Drupal 8 project root directory.
- Run civicrm_setup.sh from your project root directory.
bash ./civicrm_setup.shThis will download all the necessary modules and dependencies needed to install CiviCRM.
- Now, go to the "Extend" page (at /admin/modules) and install the CiviCRM module.
- This will create a civicrm.settings.php in your "/sites/default directory" which contains information about where the database is, etc.
- This will also create all the necessary tables in your Drupal database.
- Logout of Drupal and log back in again.
- Say what? Yeah, this is needed to sync your logged-in account with CiviCRM contacts.
- Get the Civi theme to apply by going to "/civicrm/admin/setting/url?reset=1" and set the CiviCRM Resource URL to "/libraries/civicrm" and click “Save”.
- If everything worked correctly, you should see a CiviCRM link up at the top.
- Click on the CiviCRM link and you should be taken to a page like this:
- You can also confirm that the module is actually working by typing in the email of the user that you are logged in as, and it should bring up the contact in CiviCRM. This means that contacts are automatically being synced between Drupal and CiviCRM.
And that is it, you can throw your hands up in the air to celebrate, as you’ve just installed CiviCRM in a matter of minutes.
More from Acro Media
- Blog: Quickbooks Enterprise Integration in Drupal Commerce 2
- View some of our Drupal Commerce modules
- Learn more about Drupal Commerce integrations
Need a hand?
Would you like Quickbooks integrated into your Drupal Commerce website, but need a hand doing it? We've done it many times and would love to help.