Following the amazing work @david-snopek posted(blog post - CiviCRM & D8), I spent the better part of last evening trying to get CiviCRM up and running on a Drupal 8.4 BLT project.
After trying a few different approaches, unfortunately I'm now seeing the following error when trying to enable the CiviCRM Core
Module
CiviCRM must be downloaded into the libraries folder.
No matter what I try, I can't seem to get the module to recognize that civicrm is installed.
#Other things I've tried:
- manually copying the
[project_root]/vendor/civicrm-core
into [project_root]/docroot/libraries/civicrm-core
- Renaming
libraries/civicrm-core
to libraries/civicrm
- Modifying
composer.json
to try and install CiviCRM into the libraries folder:
- Creating symbolic links to the folder (my least favorite attempt)
Here is the composer.json update for number 3 above:
"require": {
"acquia/blt": "^8.3",
"phpoffice/PHPWord": "dev-zend-version as 0.13.0",
"civicrm/civicrm-core": "4.7.25"
},
...
"repositories": {
"phpword": {
"type": "vcs",
"url": "https://github.com/dsnopek/PHPWord.git"
},
"zetacomponents-mail": {
"type": "vcs",
"url": "https://github.com/civicrm/zetacomponents-mail.git"
},
"civicrm": {
"type": "package",
"package": {
"name": "civicrm/civicrm-core",
"version": "4.7.25",
"type": "drupal-library",
"source": {
"url": "https://github.com/civicrm/civicrm-core.git",
"type": "git",
"reference": "origin/master"
}
}
}
}
source: https://gist.github.com/mortenson/a5390d99013b5b8c0254081e89bb4d47
I think this has to do with an autoloader issue perhaps seeing that BLT does not use the drupal composer.json file and the instructions @david-snopek posted were for the traditional Drupal installation method.
I was able to trace the error to modules/custom/civicrm-drupal/civicrm.install:125
/**
* Returns the path to where CiviCRM is installed.
*
* @return string|void
*
* Recommended location for civicrm is in /libraries/civicrm [citation needed].
* We also allow /modules/civicrm, which seems to work fine.
*/
function _civicrm_find_civicrm() {
if ($path = drupal_get_path('module', 'civicrm')) {
if (file_exists($path . '/CRM/Core/ClassLoader.php')) {
return \Drupal::service('file_system')->realpath($path);
}
}
$path = 'vendor/civicrm/civicrm-core';
if (file_exists($path . '/CRM/Core/ClassLoader.php')) {
return \Drupal::service('file_system')->realpath($path);
}
return NULL;
}
#Notes on my process:
I ran into a couple snags with the Gist David posted.
- When running $
composer require 'phpoffice/PHPWord:dev-zend-version as 0.13.0'
, I noticed that composer was trying to add the dependency as:
"require": {
"phpoffice/PHPWord": "dev-zend-version",
"as 0.13.0"
},
This failed but I was able to get past the issue by manually adding the dependency to the composer.json file as:
"require": {
"acquia/blt": "^8.3",
"phpoffice/PHPWord": "dev-zend-version as 0.13.0",
},
Unfortunately, I then got stuck on the next step requiring civicrm-core until I read the comment a bit closer. I believe this step is now incorrect as civicrm-core 4.7.25
has been released.
#Require civicrm-core at the requested version.
#TODO: Need to keep using my fork until 4.7.25 is released!
#composer require civicrm/civicrm-core:$CIVICRM_VERSION
composer require "civicrm/civicrm-core:dev-roundearth-$CIVICRM_VERSION as $CIVICRM_VERSION"
I was able to get past that issue by updating the additional repository via:
composer config repositories.civicrm-core vcs https://github.com/civicrm/civicrm-core.git
Reference:
https://www.mydropwizard.com/blog/how-install-civicrm-drupal-8-and-why-choose-it-over-pure-drupal-crm