We have an old script in the bin folder that bootstraps Civi like so:

require_once '[whatever]/wp-content/plugins/civicrm/civicrm/civicrm.config.php';
require_once 'CRM/Core/Config.php';

But as of 4.7 this no longer works. We get:

PHP Fatal error:  Uncaught exception 'Exception' with message 'Failed to locate civicrm.settings.php. Please boot with settingsFile, search, or CIVICRM_SETTINGS; or normalize your directory structure.' in /var/www/vhosts/humanism.org.uk/wp-content/plugins/civicrm/civicrm/civicrm.config.php:125

I've tried hardcoding the link as recommended here. This gets me a step further, but it then can't find the CMS root folder. And I'm not sure where to set that. I've also tried creating a settings_location.php file to no avail.

I've tried to modernise it by using cv as per the wiki, but I get the same problem:

Failed to locate civicrm.settings.php. By default, this tool searches the parent directories for a standard CMS (Drupal, WordPress, etal) and standard civicrm.settings.php. Symlinks and multisite configurations may interfere. To customize, set variable CIVICRM_SETTINGS to point to the preferred civicrm.settings.php

Civi runs fine otherwise - it's just external scripts that aren't happy.

Any ideas? We're on WordPress, with a standard folder structure: Civi sits in /wp-content/plugins/civicrm.


Sorted. The problem was that the script was being run by the web server cron, rather than civi cron. As such the working directory was my home directory. Hacky fix is:

eval(`cv php:boot`);

Better fix is to make it run via Civi cron.

Your Answer

