• Increase font size
  • Default font size
  • Decrease font size
Home FAQs Developers How can I get the value of a Joomla! configuration setting

How can I get the value of a Joomla! configuration setting

Some important global configuration settings are stored in configuration.php located inside Joomla! root folder.

This is an excerpt of a hypothetical configuration.php file

<?php
class JConfig {
  ...
  var $host = 'localhost';
  var $user = 'my_user';
  var $db = 'my_db';
  ...
  var $sitename = 'My Great Joomla! Site';
  ...
}
?>

If you need to know the value of one or more of these settings you can use the getCfg() method of JApplication.

Example

$app =& JFactory::getApplication();

echo $app->getCfg('sitename'); //outputs site name
echo $app->getCfg('host'); //outputs database host
echo $app->getCfg('user'); //outputs database user
echo $app->getCfg('db'); //outputs database name

The example should be clear. We get a reference of the global JApplication object, then call getCfg() passing an identifier of a member variable of the class JConfig as argument. The function returns the value of that particular setting.

 

Support the development of our open source products.
FeedSubscribe to our feed with announcements of new products and updates