Updating SugarCRM Configuration on the Fly
Use Config Manager to easily update configuration on the fly - but use it carefully, only in TEST environments.
The Need
There is often a need to update the configuration of a live SugarCRM installation, especially in cloud. Some uses cases are testing, flipping an emergency switch, etc.
But - unless you have access to the file system, there is no easy way to do it other than re-installation, or uploading a package file manually.
Solution
We developed an Admin Configuration Panel which can be used to update them at runtime. But this should be used with care, so we added a password (that could be added to the DB or config_override.php
) for any updates, but searches can be simple.
We've also added filtering so that it doesn't display any password or keys in the UI, and it's enabled only for Admins, of course!
Use it at your own risk!
Our source code and package can be downloaded from our Github Repo:
The Internals
The way the package works is by adding a new Admin panel first - this is done by creating a new file in the Extension directory:
<?php
$admin_option_defs = array();
$admin_option_defs['Administration']['ConfigManager'] = array(
'Administration',
'LBL_CONFIG_MANAGER', //Link title
'LBL_CONFIG_MANAGER_DESCRIPTION', //Link Description
'./index.php?module=Administration&action=ConfigManager'
);
$admin_group_header[] = array(
'LBL_RUNTIME_CONFIGURATION',
'',
false,
$admin_option_defs,
'LBL_RUNTIME_CONFIGURATION_DESCRIPTION' //Description of tab
);
Once we add a language file, the admin panel will look like this:

Then we have to build the User interface to search/update configurations. The Admin UI will expect a file named ConfigManager.php
, which we'll create under custom/modules/Administration
. Since Sugar Admin is mostly using Legacy 6 UI, we create a template file as well for rendering.
Reading the config
As you might know already, the sugar config is available as part of global $sugar_config
variable.
The user interface will submit a backend form, which reads from sugar config and pretty prints it into a pre
tag, simple.
The main think to notice is that this supports nested arrays, so you can use a syntax like: resource_management.default_limit
.

To mask passwords, we search the key by keywords, that is specified in files/ConfigManager.php
// TODO - Update the keywords you don't want to show in the UI
const CONFIG_KEYS_TO_MASK=['pass', 'key'];
Updating the config
We have to be careful here, but this mainly works by updating the config_override.php
using Configurator
:
require_once 'modules/Configurator/Configurator.php';
$configuratorObj = new Configurator();
$configuratorObj->loadConfig();
$configuratorObj->config[$key] = $value;
$configuratorObj->saveConfig();
echo "Configuration Updated Successfully!";
The UI to update config should be protected, of course. So we added a simple password that could be set during installation, or could be set using $sugar_config
or even use Admin config db - but for simplicity, the package just uses a default password that is present in the files/ConfigManager.php
.
// This password is used to validate if the request is valid. Change it!
// This is just a basic check. Don't want to hardcode move it to sugar_config
const CONFIG_MANAGER_PASSWORD='****';

Alternatives to Update
We're also ensuring that passwords or keys cannot be updated, since it's potentially risky. An alternative is to allow only certain fields to be updated. We could tweak it for you, let us know!
const CONFIG_KEYS_TO_DENY_UPDATE=['pass', 'key', 'dbconfig'];
Packaging
SugarCRM uses manifest.php to define how to install files, for simplicity, we created all files under the files
directory. The manifest then specifies where to install the files:
$installdefs = array(
'id' => 'config_manager',
'copy' => array(
array(
'from' => '<basepath>/files/ConfigManager.php',
'to' => 'custom/modules/Administration/ConfigManager.php'
),
array(
'from' => '<basepath>/files/ConfigManager.tpl',
'to' => 'custom/modules/Administration/ConfigManager.tpl'
),
),
'administration' => array(
array(
'from' => '<basepath>/files/ConfigManagerAdminLink.php',
'to' => 'custom/Extension/modules/Administration/Ext/Administration/ConfigManagerAdminLink.php'
),
),
'language' => array(
array(
'from' => '<basepath>/files/en_us.ConfigManager.php',
'to' => 'custom/Extensions/modules/Administration/Ext/Language/en_us.ConfigManager.php',
'to_module' => 'Administration',
'language' => 'en_us'
)
)
);
Here is the final directory structure:
├── sugarcrm-config-manager
│ ├── files
│ │ ├── ConfigManagerAdminLink.php
│ │ ├── ConfigManager.php
│ │ ├── ConfigManager.tpl
│ │ └── en_us.ConfigManager.php
│ ├── manifest.php
│ ├── README.md
To package, ensure that the manifest.php is in the root folder - i.e you have to create the zip from inside the sugarcrm-config-manager
folder:
~/code/sugar/packages/sugarcrm-config-manager zip -r ../sugarcrm-config-manager.zip .
adding: README.md (deflated 50%)
adding: manifest.php (deflated 66%)
adding: files/ (stored 0%)
adding: files/ConfigManager.tpl (deflated 74%)
adding: files/ConfigManager.php (deflated 66%)
adding: files/ConfigManagerAdminLink.php (deflated 50%)
adding: files/en_us.ConfigManager.php (deflated 54%)
You can then just zip the folder and upload the package to module loader, or download the packaged release and source code from our Github repo below.