Getting to grips with CiviCRM in Drupal 8

03 May 2019

I have developed a few websites for non-profit associations who want full integration of their membership database, online registrations and online payments. All these sites have been in Drupal 7 and I have used the RedHen modules to reasonably good effect. It has not been flawless but the best solution I could find at the time.


As I plan the upgrade to Drupal 8 for these websites over the next 1-2 years, I have been looking for an alternative to RedHen, partly because the Drupal 8 versions of these modules are not yet mature. But I also thought my customers would benefit from a more full-featured solution.


After looking at other options I decided to give a full trial to CiviCRM. I have a small amount of experience of it as a standalone product from ten years ago, and am aware of some of its advantages and disadvantages. But would it work on Drupal 8?


My trial has, at time of writing, been pretty successful, so I thought I would document some of my learnings in the hope that they will save time for others who may considering this path.


The starting point was the excellent blog by David Snopek at Not being a developer it took me a little while to get Bower and other dependencies set up, but eventually I managed to get everything downloaded correctly by composer. I then installed Drupal before using the additional steps at get CiviCRM running. Logging out and then again was essential, as described in these instructions.


Since this was the first time I had used Drupal and CiviCRM together it took me a moment to understand that the administrative interfaces are totally separate. I needed to click on CiviCRM in the top menu to go to the CiviCRM administration, and then on the main Administration link to return to Drupal admin.


I had some problems with Drush throwing up errors, so had to add two extra lines to the $databases variable in settings.php, since I use MAMP PRO on my local server:


$databases['default']['default'] = array (

  'database' => 'dbname',

  'username' => 'root',

  'password' => 'root',

  'prefix' => '',

  'port' => '3306',

  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',

  'driver' => 'mysql',

  'host' => php_sapi_name() == 'cli' ? '' : 'localhost',

  'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',



To avoid any possible unintended emails flying out to test contacts, I not only installed and enabled Drupal’s Reroute Email module but also added the following to civicrm.settings.php (which lives at sites/default): define('CIVICRM_MAIL_LOG', 1);


[To be continued]