1

A wordpress install I'm adding CiviCRM to is setup in a non-standard way, specifically:

docroot
\- civicrm.settings.php
\- wp-config.php
\- content/
|  \- plugins
|  | \- civicrm
|  \- uploads
|     \- civicrm
\- wp (wp codebase in here)

I've got CiviCRM working fine, but I can't get my tests to run that rely on booting CiviCRM from cv php:boot. Trying to run CIVICRM_SETTINGS=civicrm.settings.php cv -vvv ... from the docroot just silently dies. I'm using cv version b3db22c.

  • 1
    Does it have the same problem if CIVICRM_SETTINGS contains the full path? – Tim Otten Nov 29 '16 at 19:10
  • 'fraid it makes no difference specifying the full path. And just to test, if I give a duff path it complains loudly in a big red box. – artfulrobot Nov 29 '16 at 21:10
  • 1
    I'm not well versed in this, so I could be way off, but shouldn't you be running that command from inside the wp dir, perhaps even deeper, with a full path for the CiviCRM_Settings call? Doesn't cv want to be inside the wp dir? – G H Dec 1 '16 at 15:19
2

Thanks to the helpful comments, I conclude: Yes it can, with a bit of help.

TL;DR

  • you need to define CIVICRM_CMSDIR in your code
  • you need set CIVICRM_SETTINGS as an environment var

Longer version

As far as I can work out, cv sources civicrm.settings.php before it sources wp-config.php. So if, like me, you have config set in civicrm.settings.php that depends on constants defined in wp-config.php you'll have to find a solution for that (e.g. use if (defined('...')) or put them all in a separate file and require_once(...) it.)

Then you need something like this in your civicrm.settings.php:

define('CIVICRM_CMSDIR', __DIR__ . '/wp');

Basically CiviCRM is going to expect to find wp-includes inside that directory, so adjust as you need to.

You don't need to call cv from within any particular directory, according to my tests.

You need to set the environment variable CIVICRM_SETTINGS to point to the civicrm.settings.php file. This can be a relative or absolute path.

I was then able to get cv to run, e.g. to use the API. Now if only I could get my tests to run....!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.