Working with Config

Chyrp Lite's Config class provides an interface to get and set persistent configuration settings for the site. Extension authors are strongly encouraged to use the Config class to store all settings required by an extension. The optimal place to add settings is in the __install() method of a module or feather. Settings should be removed in the __uninstall() method when the extension is disabled.

The Config Class

You can access a singleton reference to the Config class using Config::current().

Reading Configuration Settings

Upon instantiation, the class will read the configuration from file and create a public attribute for each named configuration setting discovered in the file. This means that getting the value of a setting is as simple as accessing the desired attribute of the Config class, e.g. Config::current()->name. Note that modifying an attribute directly will not result in a permanent change to the modified value; use the set() method instead.

Creating, Updating, and Deleting

set($setting, $value, $fallback = false)

Use the set() method to add a new setting to the configuration file or update the value of an existing setting. The name can be any non-numeric string, and the value can be any JSON-encodable data. For example:

Config::current()->set("name", "My Site");
Config::current()->set("my_array", array("one", "two", 3));

The method will return the number of bytes written if successful, or false in case of failure. If $fallback is true, the supplied value will only be written to the configuration file if the setting does not already exist; in this case, possible return values are true if the setting already exists, bytes written for a successful write, and false in case of failure.


Use the remove() method to permanently remove a setting from the configuration file. For example:


The method will return the number of bytes written if successful, or false in case of failure.