Os arquivos de configuração
There are two main config files in HelloCloud, both of which are in the root HelloCloud folder. These are config.php
and config_override.php
. The definitions in here provide various configuration options for HelloCloud. All the way from the details used to access the database to how many entries to show per page in the list view. Most of these options are accessible from the HelloCloud administration page. However some are only definable in the config files.
config.php
This is the main HelloCloud config file and includes important information like the database settings and the current HelloCloud version.
Generally settings in this file wont be changed by hand. An exception to this is if HelloCloud has been moved or migrated. In which case you may need to change the database settings and the site_url. Let’s look at the database settings first:
'dbconfig' =>
array (
'db_host_name' => 'localhost',
'db_host_instance' => 'SQLEXPRESS',
'db_user_name' => 'dbuser',
'db_password' => 'dbpass',
'db_name' => 'dbname',
'db_type' => 'mysql',
'db_port' => '',
'db_manager' => 'MysqliManager',
),
Here we can see this instance is setup to access a local MySQL instance using the username/password dbuser/dbpass and accessing the database named ‘dbname’.
The site url settings are even simpler:
'site_url' => 'http://example.com/hellocloud',
The site url for the above is simply ‘http://example.com/hellocloud’ if we were moving this instance to, for example, suite.example.org, then we can simply place that value in the file.
These are generally the only two instances where you would directly change config.php
. For other changes you would either make the change through HelloCloud itself or you would use the config_override.php
file.
config_override.php
config_override.php
allows you to make config changes without risking breaking the main config file. This is achieved quite simply by adding, editing or removing items from the $sugar_config variable. The config_override.php
file will be merged with the existing config allowing, as the name suggests, overriding the config. For example in config_override.php we can add our own, new, config item:
$sugar_config['enable_the_awesome'] = true;
or we can edit an existing config option in a very similar manner by simply overwriting it:
$sugar_config['logger']['level'] = 'debug';
Using config options
We may want to access config options in custom code (or as detailed above if we have created our own config setting we may want to use that). We can easily get the config using the php global keyword:
function myCustomLogic(){
//Get access to config
global $sugar_config;
//use the config values
if(!empty($sugar_config['enable_the_awesome'])){
doTheAwesome();
}
}