As I understand it, the current values of a component configuration are stored as JSON in the params field of the #__extensions database table, in the entry that matches the component name as element. Presumably the recommended way to obtain the current configuration is:

$params = ComponentHelper::getParams($element)

(although the user side application object has a method for obtaining the configuration without specifying the element, this seems not to exist on the admin side).

The configuration can be changed in software using:

$params->set($name, $value);

The issue then is how to store the new configuration. Ideally one might use a method in Joomla, but I cannot find a suitable one. Does one exist?

Assuming the storing has to be done by a database update, I find (by experiment) that the $params object converted to string cannot be used in a SQL statement because of problems of character escaping. Although it makes legal SQL, the result is that Joomla can no longer handle the configuration. In order to get storage to work, I have derived the following:

    $sql = "UPDATE #__extensions SET params = '%s' WHERE type = 'component' AND element = 'com_example'";
    $json = str_replace('\\\\"', '\\\\\\"', addcslashes($this->params, '"'));
    $sql = sprintf($sql, $json);

This works for the fairly complex configuration I am using. But my question is, does it work for all possible configurations? And is there an easier way?

  • 1
    It is not recommended to roll your own db-escaping technique. Please use Joomla's query building helper functions and associated escaping methods. Commented May 1, 2021 at 9:07
  • Yes thanks, of course, I should have used the database escape. I don't like the query builder though. And I'm still surprised there appears to be no Joomla method available for doing this.
    – mbrampton
    Commented May 1, 2021 at 9:32

2 Answers 2


I suggest you take a look at the LibraryHelper class. Looking at the source for this, it gives access to the extensions table and contains the saveParams method.

Class reference is: https://api.joomla.org/cms-3/classes/Joomla.CMS.Helper.LibraryHelper.html

Source code: libraries/src/Helper/LibraryHelper.php

  • Thanks very much for making a suggestion. Sadly, I don't think it will work. The code for the saveParams method includes SQL with a WHERE that requires the extension type to be a library. One might have thought that the ComponentHelper class would have a saveParams method, but it seems not to.
    – mbrampton
    Commented May 3, 2021 at 12:18

There is no method for saving component parameters. I am using this simple function to achieve it.

public function saveParams(Registry $params)
        $db = Factory::getDbo();

        return $db->setQuery(
            'UPDATE #__extensions'
            . ' SET params = ' . $db->quote((string) $params)
            . ' WHERE element = ' . $db->quote('com_test')

So you can simply pass the result of ComponentHelper::getParams() as it a Registry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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