Download the PHP package pear/config_lite without Composer
On this page you can find all versions of the php package pear/config_lite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pear/config_lite
More information about pear/config_lite
Files in pear/config_lite
Package config_lite
Short Description Lightweight package for ini style configuration/settings text files
License PHP-3.0
Homepage http://pear.php.net/package/Config_Lite
Informations about the package config_lite
Config_Lite
Description
a simple, lightweight and fast class for ini style configuration files, with the native PHP function `parse_ini_file' under the covers.
Config_Lite is inspired by Pythons ConfigParser.
A "Config_Lite" file consists of global key/value pair (KVP) entries and optional sections, "[section]", followed by "name = value" (KVP) entries.
Installation
Pear
pear install Config_Lite-beta
Composer
Create a composer.json file and run composer install
Composers autoload example usage
Examples
A simple configuration file: `test.ini'
Read Configuration file:
Save Configuration file:
Create configuration file:
Alternative file creation with write:
Config without File - Streams, Filter or stdout:
global Configuration options (without sections) :
implemented IteratorAggregate, allows iteratation of the object with foreach:
Options
setProcessSections(bool)
Sets whether or not sections should be processed If true, values for each section will be placed into a sub-array for the section. If false, all values will be placed in the global scope.
setQuoteStrings(bool)
Sets whether or not to doubleQuote If true, everything but bool and numeric values get doublequoted.
Notes & Limitations
- Config_Lite is an OO frontend to
parse_ini_file
and writing ini files, but you can also use the public methodwrite
if you only want to write an array as ini file - Use getString and setString to save and read Strings with double and single-quotes
- Use getBool if you need a real bool type, eg. for strict equality comparison
- The methods
set
andget
keep values untouched, but the write method normalize "bool" values to a human readable representation, doublequotes strings and numeric values without any quotes - newline chars defaults to "\n", editable with `setLinebreak'
- comments get dropped when writing after reading
- backslashes in doublequoted values get parsed, to omit this, use
$config->read('/test.cfg', INI_SCANNER_RAW);
- no support of comments and multiline strings, because reading with
parse_ini_file
does not support it
If you want to save userinput like images, i'd recommend to use get
with base64_decode
and set
with base64_encode
.
For a regex one could also use setSingleTickDelimiter()
.
Save regex (as global option) base64 encoded :
IDEAS
- Config_Lite_Ini ( https://github.com/pce/Config_Lite_Ini ) with metainfos to supports global sections,
- support of comments and multiline strings (both supported by Pear::Config)
Credits
- @see contributors
- mfonda ensured toString and output are equal, added accessors and options
- CloCkWeRX improvements and Jenkins Integration
- cweiske for various suggestions
Contributing
Patches are Welcome!
Create an Issue with a Link to your forked branch.
https://github.com/pce/config_lite
or report bugs at: http://pear.php.net/package/Config_Lite