-
-
Notifications
You must be signed in to change notification settings - Fork 45
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.
You can access a singleton reference to the Config class using Config::current()
.
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.
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:
Config::current()->remove("name");
The method will return the number of bytes written if successful, or false
in case of failure.
This is the wiki for Chyrp Lite: An ultra-lightweight blogging engine, written in PHP.
- About Permissions
- Tour of a Theme
- Twig Reference
- Twig Variables
- Object Attributes
- Routes and Controllers
- Making Your First Module
- Debug and Tester Modes
- About Errors
- Introduction to Helpers
- Introduction to Translations
- Introduction to Triggers
- Anatomy of info.php Files
- Anatomy of a Feather
- Anatomy of a Module
- Anatomy of a Theme
- Anatomy of a Post
- Localizing Extensions
- Adding Ajax Functionality
- Working with JavaScript
- Working with Model
- Working with Config