Skip to content

Instantly share code, notes, and snippets.

demeritcowboy /
Last active Oct 28, 2019
Run bin/ on windows

Some things here might not be completely necessary or is not the typical way of doing it but is what worked for me.

  1. Do a regular install of drupal 7.
  2. Will need to use git-bash not git-cmd.
  3. Do an install of civicrm to get a working civicrm+drupal7 using the civicrm master tree from github plus civicrm-drupal and civicrm-packages. MAKE SURE YOU INSTALL CIVI IN A SEPARATE DATABASE, otherwise your drupal database will get wiped by this process.
  4. In the drupal root, composer require drush/drush:^8.0
  5. Update path so that it can find that drush.
  6. Optionally update path so that it can find node_modules/karma/bin/karma. It's optional because otherwise it will try to install it again but that also works. It doesn't get used here anyway.
  7. Create bin/setup.conf from bin/setup.conf.txt. Note that you need GENCODE_CMS=Drupal not lower-case drupal as it suggests.
  8. CIVISOURCEDIR means path to sites/all/modules/civicrm.
demeritcowboy / Install civicrm on drupal 8 on
Last active Nov 13, 2019
Install civicrm on drupal 8 using roundearth on windows - Sept 2019 version
View Install civicrm on drupal 8 on


Variation of patch below has been merged into the roundearth plugin as of 2019-11-12, so shouldn't need this anymore.


There's a problem that seems to have been around since about June 2019 where archive_tar is no longer able to extract the civicrm download .tar.gz file on windows so the install fails. These steps will get it installed.


View Set up civi coder phpcodesniffer

Add civi's fork repo to the global config. In the part where it says "repositories.civicrm-coder" the "civicrm-coder" part is arbitrary. It's just a name to give it.

composer config --global repositories.civicrm-coder git

Then install it. Change the 8.x-2.x to whatever is desired. You can look in buildkit's config to see what it's currently using: And yes you use "drupal/coder" not "civicrm/coder".

composer global require drupal/coder:dev-8.x-2.x-civi

Then follow the rest as in the readme which is the same as the original Drupal one at

demeritcowboy /
Last active Jan 3, 2020
Run civicrm unit tests in a ramdisk

Using a ramdisk for unit tests


Why do this? Tests run faster because database reloading between tests is fast.

Why not do this? If you need to keep flipping back and forth between your tests and your browser accessing your dev site or running xdebug/IDE against your dev site then this becomes awkward.

These instructions are for windows but it shouldn't be too hard to adjust for unix.

One-time setup

demeritcowboy / serverside.php
Created May 15, 2019
SubmitOnce server-side test/POC
View serverside.php
* Implements hook_civicrm_validateForm().
* @param string $formName
* @param array $fields
* @param array $files
* @param CRM_Core_Form $form
* @param array $errors
function serverside_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
demeritcowboy / Activity.php.patch
Created Feb 17, 2019
Include Case ID in Activity Detail report
View Activity.php.patch
--- CRM/Report/Form/Activity.php.orig
+++ CRM/Report/Form/Activity.php
@@ -222,6 +222,16 @@
+ 'civicrm_case_activity' => array(
+ 'dao' => 'CRM_Case_DAO_CaseActivity',
+ 'fields' => array(
+ 'case_id' => array(
View gist:89cab9859c5db2e767fa0e1f5630214b
Using php 7.1, drupal 8.6.4, civicrm 5.8.2
Set max_execution_time to 0 in php.ini. Restart httpd. (Not required on a server, but on my dev laptop 30 seconds isn't even close to enough for either the drupal or civicrm installation parts.)
Install git.
* Might be obvious, but it's not actually mentioned anywhere.
View copy_page.js
// Useful for copying a webpage full of settings from e.g. staging to live for// sites that keep their config in the database and don't have a way// to set things via files.//// Because of browser security this is a two-step process. It doesn't// do the copying, instead it generates javascript code that will set the// fields to the same values.// - Paste the code into the javascript console on the page to be copied.// - Run the code.// - Copy the output in the console log to the code console on the other page.// - Run that.//// Note this doesn't trigger event bindings, so for example for settings pages// that dynamically add fields to forms as you go it won't work perfectly, but// if a field is already on the form just hidden then it will still work.(function($) {  var s = '';  $('input[type="text"], textarea, select').each(function() {    var t = $(this);    var v = t.val();    if (v != "") {      s += '$(' + JSON.stringify('#' + + ').val(' + JSON.stringify(v) + ');' + "\n";    }  });  $('input[type