Plesk SDK API provides the ability to customize the behavior of extensions editing the panel.ini configuration file.

You can add values to panel.ini for extensions to read. They are intended to be read-only, and end users should rarely change them. For example, you can configure the “connectionTimeout” value in panel.ini instead of hard-coding it. To specify one or more values to be read by a specific extension, add a section to the file starting with [ext-<extension-id>], where <extension-id> in the id of the extension. Consider the following example:

[ext-custom-config]
timeout = 1200
homepage = "https://another-url.com"

Here, the values for timeout and homepage are specified, and they will be read only by the extension with the id “custom-config”.

Reading the values from the configuration file is implemented via the pm_Config class.

Storing the default settings is optional and is implemented via a hook class implemented within the scope of an extension. The class should be located at plib/hooks/ConfigDefaults.php and extend pm_Hook_ConfigDefaults.

Nested configuration settings are not supported.

Examples

Reading values from the configuration file

$timeout = pm_Config::get('timeout');
$homepage = pm_Config::get('homepage');

Providing the default settings

In the plib/hooks/ConfigDefaults.php file:

<?php
// Copyright 1999-2016. Parallels IP Holdings GmbH.
class Modules_CustomConfig_ConfigDefaults extends pm_Hook_ConfigDefaults
{
    public function getDefaults()
    {
        return [
            'homepage' => 'https://www.plesk.com/',
            'timeout' => 60,
        ];
    }
}

A sample extension demonstrating the principle can be found here.